fandonghua
1、字典转换为字符串(json.dumps)
jsongeshi={"name":"yajuan","age":"10"}
import json

with(open("b","w",encoding="utf-8"))as f:
json_new=json.dumps(jsongeshi) #字典转换为字符串,write写只支持字符串,不支持字典及list格式,故需转化
f.write(json_new)


2、字符串转换为字典
with(open("b",encoding="utf-8"))as f:
f1=f.read() #读f文件
f2=json.loads(f1) #字符串转换为字典
print(f2)

分类:

技术点:

相关文章:

  • 2021-12-26
  • 2021-06-07
  • 2022-01-26
  • 2022-12-23
  • 2022-01-21
  • 2021-11-13
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2021-12-09
  • 2021-04-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-27
  • 2021-07-20
相关资源
相似解决方案