It is very difficult for me to get python 3.4 to recognize a path or a text file on Windows 8. I have tried different approaches, but I get similar errors (which probably implies something simple in terms of syntax).
The file itself is located in the same folder as the script file trying to open it: C: \ Users \ User \ Desktop \ Python stuff \ Data.txt
for simplicity, the easiest way to access a file (at least I know)
f=open
These lines were encoded as:
f = open("Data.txt", "r")
and
f = open("C:/Users/User/Desktop/Python stuff/Data.txt", "r")
but return the error:
Traceback (most recent call last):
File "C:\Users\User\Desktop\Python stuff\Testscript.py", line 3, in <module>
f = open("C:/Users/User/Desktop/Python stuff/Data.txt", "r")
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/User/Desktop/Python stuff/Data.txt'
source
share