Python Forum
Update any file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Update any file (/thread-21313.html)



Update any file - Evil_Patrick - Sep-24-2019

How to update any txt file
like I want to add more lines in the text file but don't want to overwrite

with open('Text.txt', "w") as file:
    file.write('This is 2 message.')



RE: Update any file - Larz60+ - Sep-24-2019

instead of mode 'w', use mode 'a' (append)