I\'m used to doing print >>f, \"hi there\"
However, it seems that print >>
is getting deprecated. What is the recommended way t
When you said Line it means some serialized characters which are ended to '\n' characters. Line should be last at some point so we should consider '\n' at the end of each line. Here is solution:
with open('YOURFILE.txt', 'a') as the_file:
the_file.write("Hello")
in append mode after each write the cursor move to new line, if you want to use w
mode you should add \n
characters at the end of the write()
function:
the_file.write("Hello\n")