Unicode values ​​in strings escaped when flushed to JSON in Python

For instance:

>>> print json.dumps('růže') "r\u016f\u017ee" 

(Of course, in a real program this is not just one line, and it also appears in the file when using json.dump() ), I would like it to output just "růže", and also do this?

+4
source share
1 answer

Pass the argument ensure_ascii=False to json.dumps:

 >>> print json.dumps('růže', ensure_ascii=False) "růže" 
+10
source

Source: https://habr.com/ru/post/1415753/


All Articles