python: can't open file 'test.py': [Errno 2] No such file or directory
在当前目录下,运行位于另外一个目录的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脚本不在当前目录下,就必须要指定全路径?
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脚本不在当前目录下,就必须要指定全路径?
...全文
相关推荐
Python 解决相对路径问题:"No such file or directory"
主要介绍了Python 解决相对路径问题:"No such file or directory"具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
Python脚本后台运行的几种方式.docx
Python脚本后台运行的几种方式.docx
Python实现的读取文件内容并写入其他文件操作示例
本文实例讲述了Python实现的读取文件内容并写入其他文件操作。分享给大家供大家参考,具体如下: 文件目录结构,如图: read_file.py是工作文件,file_test.py是读取文件源,write_test.py是写入目标文件。 文件A:file_test.py #coding=utf-8 for i in range(1, 10): print i 文件B:read_file.py # coding=utf-8 # 打开件A f = open('./file_test.py', 'rb') # 读取文件A内容 print '---------- read file ---
py代码-python 控制台输入输出
py代码-python 控制台输入输出
Python判断文件和文件夹是否存在的方法
主要介绍了Python判断文件和文件夹是否存在的方法,本文还讲解了判断是否为文件或者目录的方法、os.path.lexist的作用、FTP中判断文件或目录是否存在等内容,需要的朋友可以参考下


