【发布时间】:2015-02-03 20:19:10
【问题描述】:
我提取了一些类似这样的 JSON 数据:
{
"string":"• Christmas 2014 •",
"layer_id":490,
"other": "attributes",
"that_dont": "matter"
}
此 JSON 正在其他地方生成,我通过 http 请求将其拉入(使用 json.loads(request.text))。
当我在控制台中打印字符串时,我得到:
⢠Christmas 2014
(如果我尝试 str(),则会出现 exceptions.UnicodeDecodeError 错误)
我在 PDF 上打印字符串,并且需要字符串字面意思是:
"\u00B7 Christmas 2014 \u00B7"
我的直觉有点老套,我只想用适当的 unicode 点替换一系列奇怪的字符,但我什至不知道我要替换的是什么。
【问题讨论】:
-
为什么是 U+00B7 而不是 U+2022?无论如何,那是原始内容;
• Christmas 2014 •.
标签: python json unicode character-encoding