## dumps 、loads是字段和json相互转换
d = {"nhy":"123456","ylm":"456789","abc":123,'bcd':'哈哈哈','sdfsd':'sdfs'}
res = json.dumps(d,indent=4,ensure_ascii=False) #把字典转成json串
f = open('user4.txt')
res = f.read()
print('res的类型',res,type(res))
d = json.loads(res) #把json串转成字典
#dump 把字典写入文件
fw = open('kqs.json','w',encoding='utf-8')
json.dump(d,fw,indent=4,ensure_ascii=False)
#load把文件转换成字典
f = open('user4.txt',encoding='utf-8')
result = json.load(f)
print(result)