0

reading file issue

file = open ('G:\\first.txt','r') print(file.read()) strn = file.read() print(strn) #This line gives '0' output file.close()

26th Mar 2017, 8:06 AM
suraj jadhav
suraj jadhav - avatar
3 odpowiedzi
+ 1
file.read() exhausts the file iterator, meaning there is nothing left after the first pass of read. Thus you have nothing in strn.
26th Mar 2017, 11:34 AM
Amaras A
Amaras A - avatar
0
Delete the second line. It's useless.
26th Mar 2017, 9:13 AM
Karlo
Karlo - avatar
0
yes I understood
26th Mar 2017, 10:02 AM
suraj jadhav
suraj jadhav - avatar