openpyxl.utils.exceptions.IllegalCharacterError

在使用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)))

原文地址:https://www.cnblogs.com/fly-kaka/p/11115538.html