- Use BBCode
- Use Python 3.x or
from __future__ import print_function
- Open a file in append mode.
- Use a context manager:
with open('file', 'a') as fd: # code pass # leaving the block, guarantees that the file is closed
- Use
fd.write('your data')
- Alternative you can use the print function. The function takes different arguments/keywords. The
file
keyword is the fileobject, where the print function writes it output. Additionally a newline is added automatic. You can also controlsep
(seperator) andend
(newline).
# inside the with block print('your data', file=fd)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!