让我澄清一下Python如何查找文件:
示例:假设在file.txt
中找到了C:\Folder
。
要打开它,你可以执行以下操作:
os.chdir(r'C:\Folder')
open('file.txt') #relative path, looks inside the current working directory
要么
open(r'C:\Folder\file.txt') #full path
Python open()提供IOError:Errno 2没有这样的文件或目录
让我澄清一下Python如何查找文件:
示例:假设在file.txt
中找到了C:\Folder
。
要打开它,你可以执行以下操作:
os.chdir(r'C:\Folder')
open('file.txt') #relative path, looks inside the current working directory
要么
open(r'C:\Folder\file.txt') #full path