ivy503

Results 1 issues of ivy503

Python代码中 json.dumps() 函数在存储中文的时候需要加入参数 `ensure_ascii=False` 才能正确存储数据到json文件。不然就会产生现在这样的编码错误。 示例代码如下: ```python >>> json_string = json.dumps("ברי צקלה", ensure_ascii=False).encode('utf8') >>> json_string b'"\xd7\x91\xd7\xa8\xd7\x99 \xd7\xa6\xd7\xa7\xd7\x9c\xd7\x94"' >>> print(json_string.decode()) "ברי צקלה" ``` 正确的用法: ```python with io.open('filename', 'w', encoding='utf8') as json_file:...