python的simplejson中的Json unicode解码

时间:2021-12-22 01:48:05

I can't decode json strings like this: "\u0e4f\u0361\u032f\u0e4f"

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

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

However php json_decode works fine:

但是php json_decode工作良好:

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

What am I doing wrong?

我做错了什么?

1 个解决方案

#1


2  

Nothing. The Python REPL prints the repr() of the string, not the string itself.

什么都没有。Python REPL打印字符串的repr(),而不是字符串本身。

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

#1


2  

Nothing. The Python REPL prints the repr() of the string, not the string itself.

什么都没有。Python REPL打印字符串的repr(),而不是字符串本身。

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