readlines()

readlines(limit)
limit : optional upper limit of bytes returned.
Output is a list of lines present inside the file.
fob=open('data.txt','r')
print(fob.readlines())
fob.close()
Output is here ( used the data.txt file given at file read() )
['This is first line\n', 'This is second line\n', 'This is third line\n', 'This is fourth line']
Using limit
fob=open('data.txt','r')
print(fob.readlines(10)) # ['This is first line\n']
fob.close()
We can use output as an iterator.
fob=open('data.txt','r')
my_data=(fob.readlines())
print(type(my_data)) # 
for x in my_data:
    print(x)
fob.close()
Output is here

This is first line

This is second line

This is third line

This is fourth line
writable()

File Append File Write
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