发布网友
共2个回答
热心网友
python 3的xlwt倒没用过,是测试版吗?
从代码来看style0没有定义过呀?可以直接用吗?
拿他的demo代码试试看呢,不能用说明版本有问题。
import xlwt3 as xlwt
from datetime import datetime
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
style1 = xlwt.easyxf(num_format_str='D-MMM-YY')
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
ws.write(0, 0, 1234.56, style0)
ws.write(1, 0, datetime.now(), style1)
ws.write(2, 0, 1)
ws.write(2, 1, 1)
ws.write(2, 2, xlwt.Formula("A3+B3"))
wb.save('example.xls')追问1. 不是style0问题,提问时为了节省行数style, font相关代码没有贴;
2. 你给的代码运行结果有一样的错误,struct.error: argument for 's' must be a bytes object, 可能真的是版本问题啊? 只是这个错误很致命啊,python3上所有excel写操作都不能用了~
追答我感觉还是安装包的问题吧,你是怎么装的?
python32下面还有一个bin目录下的xlwt.py?
我没有python3没法模拟。
他既然发布了这个包不可能连自己的demo都不能运行的。
热心网友
pypi上说了,with Python 2.3 to 2.6。
要么用2to3转一下试试?不过很有可能还是不行。
参考资料:http://pypi.python.org/pypi/xlwt
热心网友
python 3的xlwt倒没用过,是测试版吗?
从代码来看style0没有定义过呀?可以直接用吗?
拿他的demo代码试试看呢,不能用说明版本有问题。
import xlwt3 as xlwt
from datetime import datetime
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
style1 = xlwt.easyxf(num_format_str='D-MMM-YY')
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
ws.write(0, 0, 1234.56, style0)
ws.write(1, 0, datetime.now(), style1)
ws.write(2, 0, 1)
ws.write(2, 1, 1)
ws.write(2, 2, xlwt.Formula("A3+B3"))
wb.save('example.xls')追问1. 不是style0问题,提问时为了节省行数style, font相关代码没有贴;
2. 你给的代码运行结果有一样的错误,struct.error: argument for 's' must be a bytes object, 可能真的是版本问题啊? 只是这个错误很致命啊,python3上所有excel写操作都不能用了~
追答我感觉还是安装包的问题吧,你是怎么装的?
python32下面还有一个bin目录下的xlwt.py?
我没有python3没法模拟。
他既然发布了这个包不可能连自己的demo都不能运行的。
热心网友
pypi上说了,with Python 2.3 to 2.6。
要么用2to3转一下试试?不过很有可能还是不行。
参考资料:http://pypi.python.org/pypi/xlwt