Closed SoluMilken closed 5 years ago
The key of dictionary would be transformed into string type when json.dump
.
import json
A = {0: '0', 1: '1'} # key: int, value: str
with open('789.json', 'w') as filep:
json.dump(A, filep, ensure_ascii=False)
def filep
with open('789.json', 'r') as filep:
B = json.load(filep)
print(B) # returns {'0': '0', '1': '1'} key: str, value: str
A == B # returns False
please squash the last two commits
Could you be more clear about the purpose of this bug? What happened when serializing?