0

I need help with this(python)

>>> open("Test.txt", "r") Traceback (most recent call last): File "<stdin>", line 1, in <module> FileNotFoundError: [Errno 2] No such file or directory: 'Test.txt' I have no Idea what it means and what do I do... because I HAVE the file it's there!

23rd Dec 2017, 1:52 AM
Cain
Cain - avatar
5 Answers
0
If you are using SoloLearn’s environment it will not work since, it is a remote terminal. If you are using your local install then you should figure out what directory it is running from or do a direct path. Error means that it cannot find that file.
23rd Dec 2017, 2:02 AM
H Chiang
0
It’s local. If I find the path what do I do with it?
23rd Dec 2017, 4:38 AM
Cain
Cain - avatar
0
In Linux you would start from home in windows it would be c:\...\...\file Hence the command should be: open(“c:\....\...\file”,”r”) Where ... represents the full path to the file. Or you can use relative path. Similar to html local images. e.g. if the file was 2 dir down it would be something like: ./dir1/dir2/file But if it was 2 dir up and one down: ./../../dir/file
23rd Dec 2017, 5:59 AM
H Chiang
0
Ty
23rd Dec 2017, 5:07 PM
Cain
Cain - avatar
0
You don't need to mention file path. Place the file in same folder where you have script. Or you can go with above mentioned steps
11th Jan 2018, 5:37 PM
Suresh B
Suresh B - avatar