美文网首页
python之json

python之json

作者: bigtom | 来源:发表于2016-09-19 19:59 被阅读16次

JSON编码支持的基本数据类型为 None, bool, int, float 和 str, 以及包含这些类型数据的lists, tuples和dictionaries。

json.dumps 和 json.loads

import json
obj = {"foo":"bar"}
s = json.dumps(obj)
print json.loads(s)

上面演示了如何把对象转为json字符串以及如何把json字符串转为对象。

如果把字符串换为文件,则改为 json.dump 和 json.load

read more

cookbook

相关文章

网友评论

      本文标题:python之json

      本文链接:https://www.haomeiwen.com/subject/lhunettx.html