语言:Python-3.7.3 , xlrd :1.2.0
在打印如下excel值时出现以下错误。
代码:
import xlrd
class ExcelOperations():
def open_excel(self, filepath):
return xlrd.open_workbook(filepath)
def get_column_values(self, filepath):
return self.open_excel(filepath).sheet_by_index(0).cell_value(1, 0)
run = ExcelOperations()
print(run.get_column_values(run.get_column_values(localfilepath)))
Excel值
sheet1, A1(test),A2(test123)
错误:-
FileNotFoundError: [Errno 2] No such file or directory: 'test123'
代码看起来是正确的,不确定为什么会出现此错误。有人可以帮我吗?
答案 0 :(得分:1)
替换
print(run.get_column_values(run.get_column_values(localfilepath)))
使用
print(run.get_column_values(localfilepath))