wu.json文件内容如下:
{ "api_user":
{"id":1,"username":"wuyixun","email":"999999@qq.com","groups":"http://127.0.0.1:8000/groups/1/"},

"api_group":
{"id":1,"name":"Developer"}

}

第一种读取方式
with open("wu.json","r") as f:#打开并读取json文件中的内容
datastr=json.load(f)#将json格式转换为python数据类型,返回值为字典类型
print(datastr)

另一种方式
db=DB()
f = open('wu.json', 'r')
datas = json.load(f)
db.init_data(datas)


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-09-16
  • 2021-09-10
  • 2021-06-09
  • 2022-01-08
猜你喜欢
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
相关资源
相似解决方案