Python does not adds text to file (although file is created) when run inside IDLE. But if run directly by using cmd or double clicking the file, it works fine. What might be the problem? Code -
f = open('ERROR.txt', 'a')
f.write("hello")
f.close
I am using python 3 on windows 10. Note: this is not duplicate. All other questions end by closing the file, but in my case, I already have closed the text file.
f = open('ERROR.txt', 'a')
f.write("hello")
f.close()
Well, the problem is that f.close() is method of file class, and you call f.close instead of function. Try this code above
Another question, if you run your code does the file contain any text?