Monday, 23 January 2017

to read enter file and based on line number - python

fileOpen=open('C:\Users\Vishnuyardini\Documents\my goal.txt','r')
print("file name...."+fileOpen.name)
#to read file based on line number
line= fileOpen.readline()
print "Read Line: %s" % (line)
#read line till eof
while True :
    line = fileOpen.readline()
    print line
    if ("" == line):
        print "file finished"        break

No comments:

Post a Comment