import json # # 假设有一个 JSON 对象 # data = { # "name": "John", # "age": 30, # "city": "New York" # } # # # 将 JSON 对象转换为字符串 # json_str = json.dumps(data) # # print(json_str) # str 转json 类型是字典 data_str= '{"name": "John", "age": 30, "city": "New York"}' data_json=json.loads(data_str) print(type(data_json)) #<class 'dict'> print(data_json['name']) # 从字典中获取dict[key]=value John
标签:json,dict,str,print,John,data From: https://www.cnblogs.com/haha1988/p/17579546.html