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

Questions

  1. Enter name , mark in four subjects for students by creating a CSV file. A CSV file ( Comma separated value ) stores records in rows and each data is separated by comma. Here is a sample csv file data.
    1,Ravi,20,30,40,120
    2,Raju,30,40,50,130
    3,Alex,40,50,60,140
    4,Ronn,50,60,70,150

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





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