I\'m used to doing print >>f, \"hi there\"
print >>f, \"hi there\"
However, it seems that print >> is getting deprecated. What is the recommended way t
print >>
Since 3.5 you can also use the pathlib for that purpose:
Path.write_text(data, encoding=None, errors=None) Open the file pointed to in text mode, write data to it, and close the file:
Path.write_text(data, encoding=None, errors=None)
Open the file pointed to in text mode, write data to it, and close the file:
import pathlib pathlib.Path('textfile.txt').write_text('content')