Append Text to File using Python

open function & write method

filename = 'test.txt'

with open(filename, 'a') as fp:
    fp.write('Hello\n')

Leave a Comment

Cancel reply

Your email address will not be published.