json.dumps : dict转成str
json.loads:str转成dict
dict_ = {1: 2, 3: 4, "55": "66"} print(type(dict_), dict_) #<class ‘dict‘> {‘55‘: ‘66‘, 1: 2, 3: 4} json_str = json.dumps(dict_) print(type(json_str), json_str) #<class ‘str‘> {"55": "66", "1": 2, "3": 4} dict_2 = json.loads(json_str) print(type(dict_2), dict_2) #<class ‘dict‘> {‘55‘: ‘66‘, ‘1‘: 2, ‘3‘: 4}
时间: 2024-11-02 23:28:09