大家看看这段代码为什么会报错
# encoding:utf-8 import xlrd,xlwt def stary(names,hight,cole): staryer=xlwt.XFStyle fone=xlwt.Font fone.name=names fone.height=hight fone.bold=True fone.underline=True fone.colour_index=cole fone.outline=True staryer.font=fone a=input('请选择字体:') b=input('字体大小:') c=input('字体颜色:') book=xlwt.Workbook() new_sheet=book.add_sheet('新建工作表') new_sheet2=book.add_sheet('新建工作表2') book.save('d:\新建工作部.xsl') wookbook=xlrd.open_workbook('d:\新建工作部.xsl') sheet=wookbook.sheet_by_index(0) sheet2=wookbook.sheet_by_index(1) sheet.write(0,0,'实验',stary(a,b,c)) book.save('d:\新建工作部.xsl')
这是报错信息
请选择字体:'Time New Roman'
字体大小:500
字体颜色:3
Traceback (most recent call last):
File "D:/S14/python模块/xlrd模块.py", line 23, in <module>
sheet.write(0,0,'实验',stary(a,b,c))
AttributeError: 'Sheet' object has no attribute 'write'