我想用Python读取JSON文件。问题在于JSON文件将表情符号作为某些值。 JSON文件如下所示:
{"data": [{"id": "18012853735218880", "from": {"username": "g7741952"}, "text": "T\ud83d\ude0d\ud83d\ude0d\ud83d\ude0d", "created_time": "15562685603"}], "meta": {"code": 200}}
文本值为表情符号。我已经尝试过了:
data = json.load(open('comments.json'))
print(data)
我收到此错误:
UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 84-84: Non-BMP character not supported in Tk
然后我尝试了这个:
data = json.load(open('comments.json', encoding='utf16'))
print(data)
我收到此错误:
UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x7d in position 176: truncated data
我不知道下一步该怎么做,我已经搜索了所有公开的站点