标签:并且 json lin highlight with dump code print user
1 import json 2 3 #将数据存入json文件 name:[gender,age,password] 4 user_dict = {"tracy": ["female",16,"123456"], 5 "bella": ["female",17,"password"], 6 "colin": ["male",18,"colin"] 7 } 8 #写入json文件 9 with open(‘userinfo.json‘, ‘w‘) as json_file: 10 json.dump(user_dict, json_file) 11 #读取json文件并打印 12 with open(‘userinfo.json‘, ‘r‘) as json_file: 13 load_dict = json.load(json_file) 14 print(load_dict["tracy"])
python 将dictionary 转化成json并且写入和读取json文件
标签:并且 json lin highlight with dump code print user
原文地址:https://www.cnblogs.com/ufovsuso/p/12832023.html