返回我有这样的:提取数据由pycurl
import pycurl
import pprint
import json
c = pycurl.Curl()
c.setopt(c.URL, 'https://mydomainname.com')
c.perform()
上面的代码返回一个字典是这样的:
{"name":"steve", "lastvisit":"10-02-2012", "age":12}
我要通过字典循环,得到的只是年龄:
age : 12
我想:
diction = {}
diction = c.perform()
pprint.pprint(diction["age"])
无数据返回,我得到这个错误:
TypeError: 'NoneType' object is unsubscriptable
谢谢Metijn!任何想法如何获得年龄? – mongotop 2013-03-16 19:22:37
我假设你正在使用Python 3(由异常判断,python 3.1或3.2)。 – 2013-03-16 19:35:05