字典的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!

~~~

posted on 2020-03-10 16:26  江湖乄夜雨  阅读(573)  评论(0编辑  收藏  举报