file - Python: AttributeError: 'str' object has no attribute 'readlines' -


i trying copy text mobilebuildsettings , use replace text abproject. getting following error , don't understand it.

attributeerror: 'str' object has no attribute 'readlines' 

below code:

with open("c:/abproject.build", "r+") script, open ("c:/tempfile.build","w+") newscript: abproject = ("c:/abproject.build") line in abproject.readlines():     if line == "@appidentifier@" :         newabproject.write('"' + "appidentifier : " + '"' + appidentifier.get() + '"' + "\n")     else:         newabproject.write(line) abproject.close() newabproject.close() os.remove("abproject.txt") os.remove("tempfile.buil","abproject.txt") 

in order give answer jill1993's question , take moseskoledoye's answer :

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

abproject string object. furthermore, write :

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

so if want solve script error, have write :

with open("c:/abproject.build", "r+") script, open ("c:/tempfile.build","w+") newscript: abproject = ("c:/abproject.build") 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 script should work ;)


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -