我尝试使用以下代码从python中读取一个大的xlsm文件:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from openpyxl import load_workbook
print ("01")
wb = load_workbook("data.xlsm", data_only=True)
print ("02")
print (wb.get_sheet_names())
print ("03")
它返回:
01
/usr/lib/python3.5/site-packages/openpyxl/workbook/names/named_range.py:125: UserWarning: Discarded range with reserved name
warnings.warn("Discarded range with reserved name")
02
Traceback (most recent call last):
File "/home/mbp/Merve-Bitirme/main.py", line 8, in <module>
print (wb.get_sheet_names())
UnicodeEncodeError: 'ascii' codec can't encode character '\u0131' in position 12: ordinal not in range(128)
[Finished in 77.2s with exit code 1]
如何设置openpyxl以使用utf-8? 当我搜索它时,我发现这个source code默认情况下似乎是utf-8。为什么我一直得到ascii错误?