python写json示例

#!/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)