Account
Categories

Appending Files


Definition:

In Python, when you use the append mode ("a"), it adds new data at the end of the same file without deleting the old content.

Syntax:

file_handle = open("file_name", "a")
file_handle.write("Your text here")
file_handle.close()

Example:

f = open("file1.txt", "a")
f.write("Welcome to www.edutation.com")
f.close()

Output: