import json

python转为json:json.dumps(obj)

json转为python:json.loads(obj)

 

 

import json

"""
           json                    python
[] :   json中的数组                列表 list   
{} :  json中的对象                字典dict
         true                       True
         null                       None
         false                      False

"""

li = [11,22,33,44,True,None]
# python数据 转换为json数据
res_1 = json.dumps(li)
print(res_1,type(res_1))


dic = {"a":1,"b":True,"c":None}
res_2 = json.dumps(dic)
print(res_2,type(res_2))


# json转换为python

js1 = '{"a":true,"b":false}'
res3 = json.loads(js1)
print(res3,type(res3))

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-31
  • 2022-12-23
  • 2021-12-29
  • 2021-12-26
相关资源
相似解决方案