使用xlwt进行Unicode解码错误

时间:2013-06-28 13:15:46

标签: python xlwt

我正在尝试将脚本向后移植到Python 2.4,并且出现的错误如下:

Traceback (most recent call last)
    File "vuln-excel-processor.py", line 103, in ?
        values[row][col] = str(sheet.cell(row + 1, col).value).decode('utf-8')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 44: ordinal not in range(128)

这是有问题的代码块。

for row in range(sheet.nrows - 1):
    for col in range(sheet.ncols):
        values[row][col] = str(sheet.cell(row + 1, col).value).decode('utf-8')

我发现这个页面讨论了这个错误Python - Finding unicode/ascii problems,这促使我在最后一行调用str.decode(),但是无法解决问题。关于罪魁祸首的任何想法在这里?非常感谢任何帮助。

0 个答案:

没有答案
相关问题