ITeye博客

python写json示例

polyahu · 2013-02-08 22:06 · python · 编程语言 · Markdown


#!/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类型互相转换。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。