python: can't open file 'test.py': [Errno 2] No such file or directory

yanghartai yanghartai 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在当前目录下,运行位于另外一个目录的py文件。

C:\>python Test001.py
python: can't open file 'Test001.py': [Errno 2] No such file or directory

如果指定了文件的全路径,运行正常
C:\>python c:\testdir\Test001.py
this is a test

我试图将c:\testdir加入到系统环境变量PATH里,但是仍然报错,can't open file 'Test001.py': [Errno 2] No such file or directory

是不是如果运行的py脚本不在当前目录下,就必须要指定全路径?

...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
yanghartai
脚本语言 37,738 成员 34,208 内容