我在尝试写入 Excel 工作表时低于 unicodedecodeerror。
异常类型:UnicodeDecodeError 异常值:
'ascii'编解码器无法解码位置 7 的字节 0xc3:序数不在范围内(128)无法编码/解码的字符串是:i>����R<
我的观点:
def file_write(input):
handle1=open('/tmp/filelog.txt','a')
handle1.write(str(input))
handle1.close()
workbook = xlsxwriter.Workbook('report.xlsx')
worksheet = workbook.add_worksheet()
teachertitle = "ÖĞR"
file_write(teachertitle)
worksheet.write("A4", teachertitle, titlescell)
workbook.close()
奇怪的是。File_write 函数运行良好,它将“ÖĞR”写入本地文本文件。但是当我尝试将“ÖĞR”写入excell workseeht时,它会引发错误。
我也试过 worksheet.write("A4", teachertitle.encode('utf-8'),titlescell) 但问题仍然存在。
我也有 # - - coding: utf-8 - - 在views.py的开头