Python - 从JSON获取页面ID

时间:2013-01-31 13:34:02

标签: python json

{"query":{"normalized":[{"from":"hijab","to":"Hijab"}],"pages":{"68301":{

在Linux(Python)中:

>>> data['query']['pages']
{u'68301': {u'extract': u'<p/>"</b>Hijab</b>" or "</b>\u1e25ij\u0101b</b>" (/h\u026a\u02c8d\u0292\u0251\u02d0b/, /h\u026a\u02c8d\u0292\xe6b/, /\u02c8h\u026a.d\u0292\xe6b/ or /h\u025b\u02c8d\u0292\u0251\u02d0b/;Arabic: \u062d\u062c\u0627\u0628\u200e, <small>pronounced&#160;</small>[\u0127i\u02c8d\u0292\xe6\u02d0b] ~ [\u0127i\u02c8\u0261\xe6\u02d0b]) is a veil which covers the head which is particularly worn by Muslim women beyond the age of puberty in the presence of non-related adult males.</p>', u'ns': 0, u'pageid': 68301, u'title': u'Hijab'}}

任何人都可以帮助我如何获取该号码( 68301

2 个答案:

答案 0 :(得分:3)

这个数字是字典中的一个关键词:

>>> data['query']['pages'].keys()
[u'68301']

.keys()会返回字典键列表,有关字典的完整API,请参阅Python dict type documentation

答案 1 :(得分:1)

Shine这是一本字典,你可以使用keys函数:

data['query']['pages'].keys()