+ 1

Help me in python

Can anyone tell me if I had a file and I want to do some changes in file(not overwrite) which function should I use in python

20th Feb 2022, 6:25 PM
IDIOT KID - avatar
1 Answer
+ 3
This can be achieved by setting the mode in open() to "a" (append) instead of "w" (write). For instance: open("test.txt", "a") as myfile: myfile.write("appended text") In case you want to edit a specific line instead of appending, check this example: https://www.kite.com/JUMP_LINK__&&__python__&&__JUMP_LINK/answers/how-to-edit-a-specific-line-in-a-text-file-in-python
20th Feb 2022, 7:34 PM
WildGeese - avatar