python中json.dumps

来源:互联网 发布:哈弗红标 2.0 知乎 编辑:程序博客网 时间:2024/05/22 01:39

json.dumps可以将对象转换为字符串

    str = [{"type": "简单"}]    json_str = json.dumps(str)    print json_str #输出[{"type": "u7b80u5355"}]    #不过是unicode字符串的内容    json_str = json.dumps(str,ensure_ascii=False)    print json_str #输出[{"type": "简单"}]

如果碰到了[{“type”: “u7b80u5355”}]怎么办?

    print text.decode('unicode_escape') #输出[{"type": "简单"}]
0 0