在使用openpyxl制作excel的過程中突然發現有個錯誤提示
raise IllegalCharacterError openpyxl.utils.exceptions.IllegalCharacterError
平時不怎么用這個庫,一時也摸不着頭腦,大概猜測是有非法字符,搜索一番找到一篇文章
https://cooperluan.github.io/python/2015/01/08/pandas-daochu-excel-zhong-de-luan-ma-wen-ti/
根據提示,把獲取數據的部分過濾下
import re
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE
ap_list.append(ILLEGAL_CHARACTERS_RE.sub(r'', line.get(var)))