Append to a File in python

Append to a File in python
(Last Updated On: 02/05/2023)

Python Program to Append to a File, What is Append in Python, Why We Use Append in Python

#Append to a File in python


#content of myfile.txt is
#welcome
# open the file with access mode "a"
with open("myfile.txt", "a") as f:
   f.write("new text")

Output:

The content of the file after appending a text to it is:

welcomenew text

Leave a Reply

Your email address will not be published. Required fields are marked *