我试图用Python访问Excel文件,但出现以下错误:
FileNotFoundError: [Errno 2] No such file or directory: 'input/sales-feb-2014.xlsx'
你能帮我定义一下文件的路径吗?
from xlrd import open_workbook sheet = open_workbook('input/sales-feb-2014.xlsx').sheet_by_index(0) print (sheet.cell_value(3,0))
您要么需要将完整路径添加到 open_workbook(your_full_path_comes_here)
open_workbook(your_full_path_comes_here)
你可以使用 os 在调用变量之前将模块设置为。
os
import os os.chdir(r'...your/path/input')