python json解析跳过错误_Python-如何跳过特定的JSON元素?

{

"query": {

"pages": {

"7412236": {

"pageid": 7412236,

"ns": 0,

"title": "Steve Jobs",

"extract": "

Steven Paul \"Steve\" Jobs (/\u02c8d\u0292\u0252bz/; February 24, 1955\u00a0– October 5, 2011) was an American entrepreneur, marketer, and inventor, who was the co-founder (along with Steve Wozniak and Ronald Wayne), chairman, and CEO of Apple Inc. Through Apple, he is widely recognized as a charismatic pioneer of the personal computer revolution and for his influential career in the computer and consumer electronics fields, transforming \"one industry after another, from computers and smartphones to music and movies\". Jobs also co-founded and served as chief executive of Pixar Animation Studios; he became a member of the board of directors of The Walt Disney Company in 2006, when Disney acquired Pixar. Jobs was among the first to see the commercial potential of Xerox PARC's mouse-driven graphical user interface, which led to the creation of the Apple Lisa and, one year later, the Macintosh. He also played a role in introducing the LaserWriter, one of the first widely available laser printers, to the market.

\n

After a power struggle with the board of directors in 1985, Jobs left Apple and founded NeXT, a computer platform development company specializing in the higher-education and business markets. In 1986, he acquired the computer graphics division of Lucasfilm, which was spun off as Pixar. He was credited in Toy Story (1995) as an executive producer. He served as CEO and majority shareholder until Disney's purchase of Pixar in 2006. In 1996, after Apple had failed to deliver its operating system, Copland, Gil Amelio turned to NeXT Computer, and the NeXTSTEP platform became the foundation for the Mac OS X. Jobs returned to Apple as an advisor, and took control of the company as an interim CEO. Jobs brought Apple from near bankruptcy to profitability by 1998.

\n

As the new CEO of the company, Jobs oversaw the development of the iMac, iTunes, iPod, iPhone, and iPad, and on the services side, the company's Apple Retail Stores, iTunes Store and the App Store. The success of these products and services provided several years of stable financial returns, and propelled Apple to become the world's most valuable publicly traded company in 2011. The reinvigoration of the company is regarded by many commentators as one of the greatest turnarounds in business history.

\n

In 2003, Jobs was diagnosed with a pancreas neuroendocrine tumor. Though it was initially treated, he reported a hormone imbalance, underwent a liver transplant in 2009, and appeared progressively thinner as his health declined. On medical leave for most of 2011, Jobs resigned in August that year, and was elected Chairman of the Board. He died of respiratory arrest related to his tumor on October 5, 2011.

\n

Jobs received a number of honors and public recognition for his influence in the technology and music industries. He has been referred to as \"legendary\", a \"futurist\" or simply \"visionary\", and has been described as the \"Father of the Digital Revolution\", a \"master of innovation\", \"the master evangelist of the digital age\" and a \"design perfectionist\".

\n

}

}

}

}

因此,我使用以下代码获取JSON格式的Wikipedia API提供的内容,

fetchedPage = urllib2.urlopen('https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exintro&titles=Steve%20Jobs&format=json')

Json = json.load(fetchedPage)

content = Json['query']['pages']['7412236']['extract']

print content

我可以手动输入文章的“ pageid”,因此它对单个文章的效果很好.但从更一般的角度来看,我将不得不跳过“ pageid”元素,以便直接获取任何文章的内容.

简而言之,我想实现这样的目标,

content = Json['query']['pages'][//I dont care what's in this element]['extract']

我该如何进行?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值