2016-03-31 20 views
1

我有一個看起來像這樣的JSON清單文件:字符串整數必須是整數JSON名單

{"date": "October 30, 2007 Tuesday", "body": "For those of us who have been around Aberdeen for a while, your question \"What now for the oil industry? (Evening Express, October 26) had a touch of deja vu about it. That same question has been asked almost since the day the first drop of oil was pumped out of the North Sea. In the past 30 years we have seen a constant cycle of ups and downs, booms and busts in this industry. I can predict what will happen next. There will be a period of worry and uncertainty during which there will be a scrabble to find something to keep the local economy buoyant when the oil is gone. Then an upturn will see more jobs and investment in oil, everyone will breathe a sigh of relief and the quest to diversify will go on the back burner. That will be our downfall. Major industries are prone to collapse. Look at our nation's defunct shipyards and extinct coal and steel industries. That's why it is vital we don't just panic during downturns, but start planning sensibly for our future. Our civic and business leaders need to be constantly looking for something to secure our prosperity - be it tourism, technology, bio-science or other emerging industries. We need to do it now while we are economically strong rather than waiting to see what happens when the oil roller coaster hits the buffers. N JonesEllon ", "title": "Plan now for future after oil industry dies"} 
{"date": "September 4, 2007 Tuesday", "body": "Westminster was to issue a \"hands-off\" warning today to the SNP administration at Holyrood over North Sea oil. Scotland Office minister David Cairns was to tell Offshore Europe the UK Government has no intention of devolving control over oil and gas to the Scottish Government. Mr Cairns was to say: The interests of both Scotland and the UK are best served through continued economic union and the benefits which accompany a UK-wide approach. Our thinking on this issue is therefore unequivocal - introducing needless uncertainty into an \u00a311 billion industry which supports half a million jobs is not an option for the UK Government. Before the Holyrood election, the SNP pledged to make it an priority to begin discussions with Westminster on options for the transfer of responsibility for our oil and gas resources to the Scottish Parliament. But First Minister Alex Salmond was today expected to dismiss the attack by Mr Cairns. He was due to say at the opening of the conference that he was not going to be put off by the knee-jerk negativity of the junior minister from the Scotland Office. Mr Salmond was due to deliver a positive plea to get revolutionary carbon-capture proposals for Peterhead back on track. He was to describe Mr Cairns' remarks as narrow and negative. Mr Cairns was to tell the conference at Aberdeen Exhibition and Conference Centre that North Sea oil is a UK resource and that the UK Government had no intention of devolving oil and gas powers to Holyrood for a vast array of sound reasons. Comment, Page 6 ", "title": "Salmond to hit back at 'hands off oil' warning"} 
{"date": "June 22, 2007 Friday", "body": "Everyone knows that our city needs this road and needs it built on time and on budget. The alternative is unthinkable. It would mean decades more gridlock and delays. The result would be endless frustration for drivers and a block on economic growth and future prosperity for our city. Most of us were certain that the arguments for this bypass were so compelling as to be able to sweep away any of the objections that have been raised. Yet now there is a cloud of doubt hanging over the whole project because the new administration of the Scottish Executive wants a review of its costs. That is both surprising and alarming given the level of support from all the major parties for this project with the exception of the car-hating Greens. This uncertainty is doing no one any favours. So why can't the transport minister Stewart Stevenson, pictured, come right out and say that the Scottish Executive is fully committed - no buts and maybes - to building our bypass? Unless, as Richard Baker MSP, suggests projects like our bypass are set to be sidelined. A EllisNorthfieldAberdeen ", "title": "End the doubt over our city's vital bypass"} 
{"date": "June 8, 2007 Friday", "body": "The largest nature conservation charity in Scotland has lodged objections against Donald Trump's \u00a31 billion golf development. The Scottish Wildlife Trust is concerned the golf course will destroy a natural process essential for maintaining the sand dunes on the Menie Estate, Balmedie. The American tycoon wants to build two 18-hole championship courses, a five-star hotel, a golf academy and additional amenities on the 800-acre site. But his ambitious plans, which are predicted to pump millions in the North-east economy, have met with stiff opposition from nature groups. The RSPB and Scottish Natural Heritage have already lodged formal objections with Aberdeenshire Council and now the Scottish Wildlife Trust has joined them. Planning co-ordinator Paul Gallagher said: The application maintains an unacceptable level of impact on habitats and uncertainty remains in relation to the effect on species. The process of stopping sand from getting on the golf course would destroy the natural process which keeps the sand moving. Trump Golf Links Scotland (TIGLS) must consider an alternative location for the proposal. A spokeswoman for TGLS said: We are currently reviewing all comments regarding its planning application to Aberdeenshire Council and will issue a comprehensive response which addresses the environmental concerns. [email protected] ", "title": "\u00a31 billion golf plan slammed"} 
{"date": "March 26, 2007 Monday", "body": "Homeowners were increasingly turning to fixed-rate mortgages in the face of interest rate uncertainty, research today indicated. It found August's interest rate decision saw four out of 10 homebuyers opt for fixed rates, with the proportion rising to seven out of 10 after November's rise. A third increase announced in January saw this jump to eight out of 10. The study also found both first-time buyers and existing homeowners had turned to fixed rates in increasing numbers. And around 90% of first time buyers were said to have taken out fixed rates in January. ", "title": "Buyers opting for fixed rates"} 

它由datebodytitle組成。我想通過運行代碼來讀取第一主體:

import json 

with open('AEE_2007.json') as f: 
    data = [json.loads(line) for line in f] 

for obj in data[0]: print(obj['body']) 

儘管如此,它拍攝了以下錯誤:

string integers must be integers 

任何想法,爲什麼?

親切的問候

回答

3

data[0]是一本字典 - 通過直接鍵獲得的價值:

print(data[0]['body']) 

如果你想從每個字典body值的列表:

print([obj['body'] for obj in data]) 
相關問題