Open
a file in append mode and write data to file.
Previous
Next
Home>>> f=open("/Users/harikrishna_gurram/data.txt", 'r') >>> f.read() 'first line' >>> f.close() >>> >>> f=open("/Users/harikrishna_gurram/data.txt", 'a') >>> f.write("\nSecond line") 12 >>> f.write("\nThird line") 11 >>> f.close() >>> f=open("/Users/harikrishna_gurram/data.txt") >>> f.read() 'first line\nSecond line\nThird line' >>> >>> f=open("/Users/harikrishna_gurram/data.txt") >>> for line in f: ... print(line, end='') ... first line Second line Third line
No comments:
Post a Comment