Python的simplejson中的Json Unicode解码

2 投票
1 回答
1516 浏览
提问于 2025-04-15 22:37

我无法解码这样的json字符串:"\u0e4f\u0361\u032f\u0e4f"

>>> import simplejson
>>> simplejson.loads('"\u0e4f\u0361\u032f\u0e4f"', encoding='utf8')
u'\u0e4f\u0361\u032f\u0e4f'

不过,php的json_decode函数工作得很好:

json_decode('"\u0e4f\u0361\u032f\u0e4f"');

我哪里做错了呢?

1 个回答

2

没什么特别的。Python 的交互式环境(REPL)显示的是字符串的表示形式,而不是字符串本身。

>>> print u'\u0e4f\u0361\u032f\u0e4f'
๏̯͡๏

撰写回答