问题现象及背景
openpyxl加载excel文件时,报错提示TypeError: init() got an unexpected keyword argument 'state'
代码片段
workbook = openpyxl.load_workbook(filename=self.calibration['case_path'], data_only=True) # 获取用例excel表格对象
worksheet = workbook.worksheets[self.calibration['start_sheet']]
运行结果
File "D:\PythonWorkSpace\Auto_test_wuhan\function_test\Compare_Loop.py", line 129, in run
workbook = openpyxl.load_workbook(filename=self.calibration['case_path'], data_only=True) # 获取用例excel表格对象
File "D:\Python3.8.6\lib\site-packages\openpyxl\reader\excel.py", line 346, in load_workbook
reader.read()
File "D:\Python3.8.6\lib\site-packages\openpyxl\reader\excel.py", line 301, in read
self.read_worksheets()
File "D:\Python3.8.6\lib\site-packages\openpyxl\reader\excel.py", line 237, in read_worksheets
ws_parser.bind_all()
File "D:\Python3.8.6\lib\site-packages\openpyxl\worksheet\_reader.py", line 465, in bind_all
self.bind_cells()
File "D:\Python3.8.6\lib\site-packages\openpyxl\worksheet\_reader.py", line 368, in bind_cells
for idx, row in self.parser.parse():
File "D:\Python3.8.6\lib\site-packages\openpyxl\worksheet\_reader.py", line 163, in parse
obj = prop[1].from_tree(element)
File "D:\Python3.8.6\lib\site-packages\openpyxl\descriptors\serialisable.py", line 103, in from_tree
return cls(**attrib)
TypeError: __init__() got an unexpected keyword argument 'state'
尝试过的方法
1.尝试删掉data_only=True
2.尝试升级openpyxl
代码片段截图