[Solved] Python: AttributeError: ‘str’ object has no attribute ‘readlines’


In order to give a good answer to jill1993’s question and take the MosesKoledoye’s answer :

abproject = ("C:/abproject.build")

abproject is a string object. Furthermore, you write :

with open("C:/abproject.build", "r+") as script

So if you want to solve your script error, you have to write :

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")

And your script should work 😉

solved Python: AttributeError: ‘str’ object has no attribute ‘readlines’