首页 > 编程语言 > 详细

Python json

时间:2020-02-27 16:28:47      阅读:56      评论:0      收藏:0      [点我收藏+]

原文:https://www.runoob.com/python3/python3-json.html

 

import json

data1 = {
    no : 1,
    name : Runoob,
    url : http://www.runoob.com
}


# 对象 转换为 字符串
json_str = json.dumps(data1)


# 将json数据写入到文本
with open(data.json, w) as f:
    json.dump(json_str, f)


# 从文本中读取json数据
data2={}
with open(data.json, r) as f:
    data2 = json.load(f)
print(data2)

 

Python json

原文:https://www.cnblogs.com/guxingy/p/12372211.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!