[英]Python openpyxl telling me " No such file or directory:" even though python file is in same directory as the excel file, among others
[英]I am getting: "No such file or directory: 'data.xlsx'" error message, even though I have my python file in the same file as the Excel file
使用os.getcwd()
找出 python 的当前工作目录。
import os
os.getcwd()
cd my_desired_directory
或者只是设置你的目录:
os.chdir("desired_directory_from_root")
使用文件的完整路径来读取它。 例如:
C:/Users/ihovl/helloworld/.vscode/data.xlsx
或类似的东西。 准确找到文件的路径并将其传递给pd.ExcelFile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.