i want to write a string to a file and every time i use file.write( )it should write on a new line in my file
please tell how can i do this
i want to write a string to a file and every time i use file.write( )it should write on a new line in my file
please tell how can i do this
You can do this in two ways:
f.write("text to write\n")
or, depending on your Python version (2 or 3):
print >>f, "text to write" # Python 2.x
print("text to write", file=f) # Python 3.x