字典的key为int时经过序列化、反序列化操作后会变成str
import json dic1 = {1:1} dic1_dum = json.dumps(dic1) dic1_loads = json.loads(dic1_dum) for i in dic1_loads.keys(): print(i,type(i)) # 1 <class 'str'> ———— key为int时经过序列化、反序列化后变成了str类型! print(dic1_loads["1"],type(dic1_loads["1"])) # 1 <class 'int'> ———— value为int经过序列化、反序列化后仍是int!
~~~