json.loads pk json.dumps

  • json.loads(str) 加载
    加载string ,把string转化成dict
  • json.dumps(dict) 卸货
    卸货成string,把dict转化成string
python
import json
dict_ = {1:2, 3:4, "55":"66"}

#test json.dumps
print type(dict_), dict
json_str=json.dumps(dict_)
print type(json_str), json_str

#test json.loads
dict_2=json.loads(json_str)
print type(dict_2), dict_2

运行结果:

猜你喜欢

转载自blog.csdn.net/love_parents/article/details/74931722