python 将dictionary 转化成json并且写入和读取json文件
import json #将数据存入json文件 name:[gender,age,password] user_dict = {"tracy": ["female",16,"123456"], "bella": ["female",17,"password"], "colin": ["male",18,"colin"] } #写入json文件 with open(‘userinfo.json‘, ‘w‘) as json_file: json.dump(user_dict, json_file) #读取json文件并打印 with open(‘userinfo.json‘, ‘r‘) as json_file: load_dict = json.load(json_file) print(load_dict["tracy"])
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16