import json #字符串形式的json数据转化为字典 str = ‘{"name":"Jack","age":28}‘ print(json.loads(str)) #将字典转成json d = {"name":"Jack","age":28} print(json.dumps(d)) #将转换后的json数据写入文件 #d = {"name":"Jack","age":28} #json.dump(d,open("test.txt","w")) #以字典形式读json文件 print(json.load(open("test.txt","r")))
时间: 2024-12-12 06:03:45