python中的json
生活随笔
收集整理的這篇文章主要介紹了
python中的json
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?
?
import json# dumps #一般處理字符串
# dump #一般處理文件
#字符串和json之間的轉(zhuǎn)換
test_dict={"name":"fxh","age":23}
a=json.dumps(test_dict)
print(a,type(a))
b='{"name": "fxh", "age": 23}'
c=json.loads(b)
print(c,type(c))
#文件和json之間的轉(zhuǎn)換
test_dict={"name":"fxh","age":24}
with open("j.txt","w+") as fd:
json.dump(test_dict,fd)
with open("j.txt","r+") as f:
m=json.load(f)
print(m)
轉(zhuǎn)載于:https://www.cnblogs.com/fanxuanhui-linux/p/7828736.html
總結(jié)
以上是生活随笔為你收集整理的python中的json的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: weex开发前配置
- 下一篇: 提前批警校政审提交了可以不报公安大学吗不