【发布时间】:2013-03-05 10:03:29
【问题描述】:
我有这个:
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
【问题讨论】:
-
谢谢你!知道如何计算年龄吗?
-
我假设您使用的是 Python 3(根据例外情况判断,python 3.1 或 3.2)。
标签: python dictionary pycurl