详细出错信息如下:import xlwt3
解决办法如下:Traceback (most recent call last):File "F:\temp\mycode\frist\frist.py", line 132, in <module>import xlwt3File "C:\Python33\lib\site-packages\xlwt3\__init__.py", line 3, in <module>from .workbook import WorkbookFile "C:\Python33\lib\site-packages\xlwt3\workbook.py", line 5, in <module>from .worksheet import WorksheetFile "C:\Python33\lib\site-packages\xlwt3\worksheet.py", line 7, in <module>from .row import RowFile "C:\Python33\lib\site-packages\xlwt3\row.py", line 8, in <module>from . import formulaFile "C:\Python33\lib\site-packages\xlwt3\formula.py", line 6, in <module>class Formula(object):ValueError: '__init__' in __slots__ conflicts with class variable
__slots__ = ["__init__", "__s", "__parser", "__sheet_refs", "__xcall_refs"]
__slots__ = [ "__s", "__parser", "__sheet_refs", "__xcall_refs"]
struct.error: argument for ‘s’ must be a bytes object
解决办法:
修改为def __init__(self, owner): uowner = owner[0:0x30] uowner_len = len(uowner) self._rec_data = pack('%ds%ds' % (uowner_len, 0x70 - uowner_len), uowner, b' '*(0x70 - uowner_len)) # (to_py3): added b'...'
原文网址: http://ljchu.blog.163.com/blog/static/213753199201301062134786/def __init__(self, owner):
uowner = owner[0:0x30]
uowner_len = len(uowner)
self._rec_data = pack('%ds%ds' % (uowner_len, 0x70 - uowner_len),
uowner.encode('utf-8'), b' '*(0x70 - uowner_len)) # (to_py3): added b'...'