当我尝试运行程序时出现此错误:
IOError: [Errno 2] No such file or directory: 'C:/Users/Admin/Desktop/PythonProgram/sample.xls'
我尝试用\替换/斜杠,但无济于事。断言也不起作用,我肯定名称和文件目录都是正确的。此外,将其更改为sample.xlsx不起作用。
以下是代码:
import xlrd
import os.path
data_folder = "C:/Users/Admin/Desktop/PythonProgram/"
file_name = "sample.xls"
wb = xlrd.open_workbook(os.path.join(data_folder, file_name))