python+pandas+openpyxl下载xls illegalCharacterError

仅仅是urllib2.unquote_plus解码是不够的,需要将特殊字符去掉

ILLEGAL_CHARACTERS_RE = re.compile(r'[00-10]|[13-14]|[16-37]|xef|xbf')
value = ILLEGAL_CHARACTERS_RE.sub('', origin_value)
由于xef|xbf的存在,导致字符串乱码,查了一下这是作为utf-8 BOM的存在,需要过滤掉。

BOM: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8

ASCII Characters: http://donsnotes.com/tech/charsets/ascii.html

Then, it worked for me.

原文地址:https://www.cnblogs.com/bierxiaobia/p/9429547.html