12/5 No such file or directory: 'text.txt'


#1



12/5 Reading between the lines


I am unable to open the file "text.txt", that I'm supposed to read. The error code is:

Traceback (most recent call last):
  File "python", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'text.txt'


This is my code:

my_file = open("text.txt", "r")
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()


#2

Go to the text.txt tab and just press enter to generate a new line, after that it should work fine.


#3

Yep, that worked. Thanks.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.