python - 为什么 Charmap 只以字典形式抛出错误,而不是 JSON 形式?
问题描述
response = requests.request("GET", requestUrl, headers=headers, data=payload)
data = response.json()
dataJSON = json.dumps(data)
print (dataJSON) #Prints perfectly fine
#dataDict = json.loads(dataJSON)
#print(dataDict) #throws charmap Exception that is below
File "C:\Program Files\Python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 107450-107451: character maps to <undefined>
我已经尝试过 UTF-8 编码,但这并不能解决这个问题。预先感谢您的帮助!
解决方案
推荐阅读
- firebase - FLUTTER FIREBASE 更改为不适用于 Android 的新实例
- ios - NWNetworking/NWListener如何正确接收UDP广播消息?
- r - 在我从 csv 文件导入的数据中创建一个新列
- typescript - 键入具有许多“key: require()”条目的对象,以将所有要求作为字符串
- arguments - `{⊂⍵}` 与 `⊂` 有什么不同?
- php - php simplexml_load_file 和 CDATA 的数据完全丢失
- git - Git 提交未添加的本地更改 - 我该如何阻止它?
- python - Get all the connected components from a set of pairs in pandas dataframe
- javascript - How can I use javascript to scroll to the bottom of a textarea?
- pandas - Unable to Perform NULL value analysis in pandas dataframe