Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update any file
#1
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.')
Reply
#2
instead of mode 'w', use mode 'a' (append)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read csv file update matplotlib column chart regularly SamLiu 2 1,055 Jan-21-2023, 11:33 PM
Last Post: SamLiu
  Is it possible to update a CSS file from Python bigAL_python 4 2,262 Apr-20-2022, 01:38 PM
Last Post: bigAL_python
  value null when update in json file 3lnyn0 6 3,188 Dec-30-2021, 05:52 PM
Last Post: ndc85430
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,463 Oct-21-2021, 03:29 AM
Last Post: buran
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 2,665 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  Config file update Olivier74 0 1,473 Aug-18-2020, 03:36 PM
Last Post: Olivier74
  update txt file but keep a specific line 3Pinter 2 2,073 Dec-16-2019, 07:54 AM
Last Post: 3Pinter
  Python csv compare two file, update value if two value is matched kinojom 1 2,531 Apr-17-2019, 10:36 AM
Last Post: DeaD_EyE
  variables help / update config file mapvis 3 3,376 Nov-27-2018, 02:24 PM
Last Post: mapvis
  How do i read particular text from text file and update those values in MS SQL table ganeshsai2912 33 14,832 Nov-20-2018, 12:55 AM
Last Post: ganeshsai2912

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020