FileNotFoundError: [Errno 2] No such file or directory: error in xlrd

FileNotFoundError: [Errno 2] No such file or directory: error in xlrd

语言:Python-3.7.3xlrd: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'

代码看起来是正确的,但不确定为什么会出现此错误。有人可以帮助我吗?

替换

print(run.get_column_values(run.get_column_values(localfilepath)))

print(run.get_column_values(localfilepath))