python - How can I add more to a file when printing stdout to a file, instead of overwriting the file? -


is there way can print stdout file without overwriting file? if file reaches size, starts overwrite file? there way can achieve in python? know how print stdout file this:

sys.stdout = open('file.txt', 'w') # print stuff 

unfortunately, limited knowledge of python, can't want achieve, there way can this, or not possible? appreciated!

you can use open('file.txt', 'a') append end of file rather overwrite. starting overwrite once reach size more complicated: need write new text @ right location in file, may complicated if file's lines have variable length.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -