I'm trying to read 2nd line in text.txt file:
import fileinput
x = 0
for line in fileinput.input([os.path.expandvars("$MYPATH/text.txt")]):
if x < 3:
x += 1
if x == 2:
mydate = line
fileinput.close()
print "mydate : ", mydate
But I get an error:
Traceback (most recent call last):
File "/tmp/tmpT8RvF_.py", line 4, in <module>
for line in fileinput.input([os.path.expandvars("$MYPATH/text.txt")]):
File "/usr/lib64/python2.6/fileinput.py", line 102, in input
raise RuntimeError, "input() already active"
RuntimeError: input() already active
What is wrong above?