python3通过pycharm编译器调用requests接口返回JSON格式Unexpected UTF-8 BOM (decode using utf-8-sig)

2025-04-07 11:21:17
推荐回答(1个)
回答1:

因为你的req内容包含BOM字符,去掉req中BOM头的方法如下

if req.startswith(u''):
    req = req.encode('utf8')[3:].decode('utf8')