我正在尝试复制mobileBuildSettings
中的文字并使用它来替换{{1}}中的文字。我收到以下错误,但我不理解。
abproject
以下是我的代码:
AttributeError: 'str' object has no attribute 'readlines'
答案 0 :(得分:0)
我改变了:
for line in abproject.readlines():
为:
for line in script.readlines():
答案 1 :(得分:0)
为了对jill1993的问题给出一个很好的答案,并采取MosesKoledoye的答案:
abproject = ("C:/abproject.build")
abproject
是一个字符串对象。此外,你写道:
with open("C:/abproject.build", "r+") as script
因此,如果您想解决脚本错误,您必须写:
with open("C:/abproject.build", "r+") as script, open ("C:/tempfile.build","w+") as newscript:
abproject = ("C:/abproject.build")
for line in script.readlines():
if line == "@AppIdentifier@" :
newscript.write('"' + "AppIdentifier : " + '"' + appIdentifier.get() + '"' + "\n")
else:
newscript.write(line)
script.close()
newscript.close()
os.remove("abproject.txt")
os.remove("tempfile.buil","abproject.txt")
你的脚本应该可以工作;)