#!/usr/bin/python
import json
source = '{"name":"polyahu", "type":"title"}'
f = open('./json.data')
j = json.loads(source)
r = json.load(f)
s = json.dumps(j)
print "j's type",
print type(j)
print "s's type",
print type(s)
json.loads()和json.dumps()是将str类型和dict类型互相转换。
本文介绍了一个使用Python进行JSON数据操作的例子,包括如何利用json模块实现字符串与字典之间的相互转换。

被折叠的 条评论
为什么被折叠?



