python.json
程序员文章站
2022-03-26 21:41:54
...
代码:
# -*- coding: utf-8 -*-
# @Time : 2020/4/19 20:41
# @Author : Oneqq
# @File : 22.jsonpath的使用.py
# @Software: PyCharm
import json
str = '{"name":"盗梦笔记"}'
print(type(str))
obj = json.loads(str)
print(type(obj))
str2 = json.dumps(obj, ensure_ascii=False)
print(type(str2), ":", str2)
json.dump(obj, open("movie.txt", 'w', encoding="utf-8"), ensure_ascii=False)
str3 = json.load(open('movie.txt',encoding='utf-8'))
print(str3)
结果:
推荐阅读