Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

path - FileNotFoundError Python Script

I am trying to run a python script, .py in the windows command prompt.

I drag the script from my files into the command prompt window. I run it. Then, the script presents a prompt for me to enter the file I would like to parse. I am supposed to enter a file like this: filename.txt

When I go to do this, I get the FileNotFoundError. They are both located in my downloads folder. Any ideas as to why? I've tried a couple of things but having no luck.

The script must be performed this way because this is a script many people will use and it is likely that they will receive it and download it and the file to parse to their computer so it'll be located in their downloads folder.

When I created the script I did it in Notepad++ and had a separate folder where I put the file and script and it worked fine this way. I am just ensuring it works from the perspective of someone who's downloading it off an email or website, etc.

Thanks !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yeah that happened to me a lot.

To solve it just write the whole directory of the file.

If you are in windows

c:userusernameDesktopfile.txt

If you are in linux or mac:

/home/username/Desktop/file.txt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...