Append data to file in Python

In append (a) mode , data will be added at the end of the file. Existing data will not be overwritten.
fob=open('data1.txt','a')
fob.write("\nthis is  2nd line of text added")
You can open data1.txt and see the content inside.


To write and display
fob=open('data1.txt','a')
fob.write("\nthis is  2nd line of text added")
## Writting at the end  of file is over , now read
fob=open('data1.txt','r')
print(fob.read())
fob.close()
Output is here
this is first line of text
this is  2nd line of text added
File Read File Write
Your Rating




Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer