I have the python tool on Visual Studio 2010. I tried to open a text file, which is in the same folder with the .py file, but I am having
[Errno 2] No such file or directory: 'lines.txt'
Here is the line:
fh = open('lines.txt')
please help.
I have the python tool on Visual Studio 2010. I tried to open a text file, which is in the same folder with the .py file, but I am having
[Errno 2] No such file or directory: 'lines.txt'
Here is the line:
fh = open('lines.txt')
please help.
You should add folder's address to the code just like this.
f = open("E:\\python\\201607final\\names.txt","r")
There is your problem, if you're going to run the script as C:\folder\folder\script.py
, then your code will try to look for input.txt
in C:
. You should first navigate to the folder and then run the script simply as script.py
or python script.py
.