如何将json对象作为参数传递给python函数?
我们在下面的代码中将给定的json对象作为python函数的参数。
示例
import json
json_string = '{"name":"Rupert", "age": 25, "desig":"developer"}'
print type (json_string)
def func(strng):
a =json.loads(strng)
print type(a)
for k,v in a.iteritems():
print k,v
print dict(a)
func(json_string)输出结果
<type 'str'>
<type 'dict'>
desig developer
age 25
name Rupert
{u'desig': u'developer', u'age': 25, u'name': u'Rupert'}热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便