{
"name": "tom", "age": 18,
"isMan": true, "school": null, "address": {
"country": "中国",
"city": "江苏苏州",
"street": "科技园路"
},
"numbers": [2, 6, 8, 9], "links": [
{
"name": "Baidu",
"url": "http://www.baidu.com"
},
{
"name": "TaoBao",
"url": "http://www.taobao.com"
}
]
}
data = {
'id': 1,
'name': 'Tom',
'address': '北京市海淀区', 'school': None
}
json_str = json.dumps(data)[/mw_shl_code
with open('data.json', encoding='UTF-8') as f: data = json.load(f) # 返回的数据类型为字典或列表
param = {'name': 'tom', 'age': 20}
with open('data2.json', 'w', encoding='UTF-8') as f: json.dump(param, f)
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |