gpt4 book ai didi

python - 属性错误: 'Sheet' object has no attribute 'row_len'

转载 作者:行者123 更新时间:2023-12-01 05:48:07 27 4
gpt4 key购买 nike

我正在尝试运行 this脚本并收到错误:

Traceback (most recent call last):
File "nimeKoostaja.py", line 19, in <module>
wb = copy(book)
File "/usr/local/lib/python2.7/dist-packages/xlutils/copy.py", line 13, in copy
w
File "/usr/local/lib/python2.7/dist-packages/xlutils/filter.py", line 827, in process
reader(chain[0])
File "/usr/local/lib/python2.7/dist-packages/xlutils/filter.py", line 66, in __call__
for col_x in xrange(sheet.row_len(row_x)):
AttributeError: 'Sheet' object has no attribute 'row_len'

我使用的是 xubuntu 12.10。有趣的是,同样的代码在 Windows 7 中却不会发生这种情况。我不知道出了什么问题。

最佳答案

在我看来,您正在运行旧版本的xlrd,因为它提供了工作表。您在 xubunut 上使用什么版本的 xlrd? (或者是xubuntu)

使用此测试程序:

import os
import xlrd
print 'xlrd: ', xlrd.__VERSION__
import xlwt
print 'xlwt: ', xlwt.__VERSION__
import xlutils.copy
print 'xlutils:', open(os.path.join(os.path.dirname(
xlutils.copy.__file__), 'version.txt')).read()


from xlrd import open_workbook, cellname, XL_CELL_TEXT
from xlwt import Workbook
from xlutils.copy import copy

# open fail
book = open_workbook('name.xls')
# make copy
wb = copy(book)

print 'finished'

和不同版本的 xlrd,我得到以下输出:

2013-03-14 18:33:30.201494 ['python2.7', 'test.py']
xlrd: 0.9.0
xlwt: 0.7.4
xlutils: 1.5.2

finished

2013-03-14 18:35:40.241518 ['python2.7', 'test.py']
xlrd: 0.7.3
xlwt: 0.7.4
xlutils: 1.5.2

finished

2013-03-14 18:42:06.703188 ['python2.7', 'test.py']
xlrd: 0.6.1
xlwt: 0.7.4
xlutils: 1.5.2

Traceback (most recent call last):
File "test.py", line 19, in <module>
wb = copy(book)
File "/usr/lib/python2.7/dist-packages/xlutils/copy.py", line 13, in copy
w
File "/usr/lib/python2.7/dist-packages/xlutils/filter.py", line 827, in process
reader(chain[0])
File "/usr/lib/python2.7/dist-packages/xlutils/filter.py", line 66, in __call__
for col_x in xrange(sheet.row_len(row_x)):
AttributeError: 'Sheet' object has no attribute 'row_len'

关于python - 属性错误: 'Sheet' object has no attribute 'row_len' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15406882/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com