- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 python-requests 来处理 elasticsearch 索引。特别是我没有从 requests.json() 得到我想要的东西(在标准库中包装 json.loads() 函数)。
我正在努力处理 json() 方法返回的结果。它似乎正在返回一个字符串列表。我想要一个可以循环访问每个成员属性的 dict 对象,即......
r = requests.get(url)
results = r.json() //same as results = json.loads(json string)
print(results)
for result in results:
print(result['source'])
这是我手动使用 curl 执行搜索时 Elasticsearch 返回的内容(这是 r.json() 调用的输入):
{"took":5,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":18,"max_score":1.0,"hits":[{"_index":"feed","_type":"article","_id":"Bq2_NxWIRZS5mfX_jxv5YQ","_score":1.0, "_so urce" : {"source": ["http://www.naturalnews.com/040631_farmed_salmon_GMO_sustainable_fishing.html"], "link": ["http://www.naturalnews.com/040631_farmed_salmon_GMO_sustainable_fishing.html"], "description ": ["<table><tr><td><img src=\"http://www.naturalnews.com/gallery/300X250/Food/Salmon-Raw.jpg\" /></td><td valign=\"top\">Equally as menacing as the potential release of genetically-modified (GM) salmon into the wild, factory fish farms are a modern scourge responsible for killing off droves of native fish species all around the world. And unless immediate action is taken to address this...</td></tr></t able>"], "title": ["Fish farming killing off native species; boycott farmed salmon before it's too late"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 193}},{"_index":"feed","_type": "article","_id":"jxfFD6V-Qwacc4KYNfChcg","_score":1.0, "_source" : {"source": ["http://www.naturalnews.com/040628_calf_exercises_soleus_stretch_lower_body_workouts.html"], "link": ["http://www.naturalnew s.com/040628_calf_exercises_soleus_stretch_lower_body_workouts.html"], "description": ["<table><tr><td><img src=\"http://www.naturalnews.com/gallery/300X250/Exercise/Running-Shoes-Fitness-Legs-Calves-Mus cles.jpg\" /></td><td valign=\"top\">Building killer calves is more complicated than people think. Most exercisers do a bunch of standing calf exercises like standing calf raises, sled hack calf raises, donkey raises, and calf presses to bulk up not realizing that their entire workout is only targeting...</td></tr></table>"], "title": ["Calf exercises: Sit down to build yourself up"], "published": ["Wed , 5 Jun 2013 00:00:00 CST"], "medoozie_score": 228}},{"_index":"feed","_type":"article","_id":"RBV1P_lXStKAHeaNi-q9Bg","_score":1.0, "_source" : {"source": ["http://www.naturalnews.com/040626_Hopewood_ch ildren_natural_living_organic_foods.html"], "link": ["http://www.naturalnews.com/040626_Hopewood_children_natural_living_organic_foods.html"], "description": ["<table><tr><td><img src=\"http://www.natura lnews.com/gallery/300X250/Children/Kids-Children-Play-Outside-Happy-Exercise.jpg\" /></td><td valign=\"top\">In 1942, the founder of the Natural Health Society of Australia, Leslie Owen Bailey, began a s ocial experiment: He chose to adopt 85 children whose parents were unable to provide for them. The children's residence became the sprawling Hopewood House in New South Wales...</td></tr></table>"], "tit le": ["Honoring nature: The lesson of the Hopewood children"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 187}},{"_index":"feed","_type":"article","_id":"uP6G2_leSl2-gUMyUie3eA","_s core":1.0, "_source" : {"source": ["http://www.naturalnews.com/040636_IRS_scandal_conservative_groups_Obama_Administration.html"], "link": ["http://www.naturalnews.com/040636_IRS_scandal_conservative_gro ups_Obama_Administration.html"], "description": ["<table><tr><td><img src=\"http://www.naturalnews.com/gallery/300X250/Money/IRS-Building-Revenue-Taxes-Money.jpg\" /></td><td valign=\"top\">Officials wit h the Internal Revenue Service (IRS) have admitted that the agency inappropriately targeted conservative groups seeking legal tax-exemption status in the years and months leading up to the 2012 election. Those same officials have apologized for the targeting...</td></tr></table>"], "title": ["Claim: IRS still targeting conservative groups, even after promising the intimidation already stopped"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 342}},{"_index":"feed","_type":"article","_id":"yhcqfmKQRwSVhR1vUIy0vg","_score":1.0, "_source" : {"source": ["http://www.natu ralnews.com/040633_Bug_Eating_Festival_insects_survival_foods.html"], "link": ["http://www.naturalnews.com/040633_Bug_Eating_Festival_insects_survival_foods.html"], "description": ["<table><tr><td><img s rc=\"http://www.naturalnews.com/gallery/300X250/Women/Party-Girls-Fun.jpg\" /></td><td valign=\"top\">Are people in Austin so hungry they are eating bugs? \"Well, it does help if you c ome to the party having skipped lunch,\" says Marjory Wildcraft, the host and creator 6th Annual Bug Eating Festival which will be held on Saturday June 29, 2013 at Zilker Park in Austin...</td></tr></ta ble>"], "title": ["6th Annual Bug Eating Festival"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 252}},{"_index":"feed","_type":"article","_id":"Grh9KUDVQvSs7oRUjzOG9A","_score":1.0, "_source" : {"source": ["http://www.naturalnews.com/040630_egg_whites_blood_pressure_peptides.html"], "link": ["http://www.naturalnews.com/040630_egg_whites_blood_pressure_peptides.html"], "description" : ["<table><tr><td><img src=\"http://www.naturalnews.com/gallery/300X250/Food/Brown-Eggs-On-White.jpg\" /></td><td valign=\"top\">Considering that eggs contain all the nutrients needed to develop healthy chicks, it is unsurprising that studies into their numerous health benefits for humans abound. Eating more eggs has, for instance, been repeatedly linked to reduced LDL cholesterol, a lowered risk...</t d></tr></table>"], "title": ["Peptide found in egg whites can lower blood pressure, say researchers"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 262}},{"_index":"feed","_type":"art icle","_id":"6OfIM7G9Rke-TD3N6bI4Ow","_score":1.0, "_source" : {"source": ["http://www.naturalnews.com/040629_obesity_vitamin_D_deficiency_exercise.html"], "link": ["http://www.naturalnews.com/040629_obe sity_vitamin_D_deficiency_exercise.html"], "description": ["<table><tr><td><img src=\"http://www.naturalnews.com/gallery/300X250/Men/Big-Fat-Hairy-Obese-Belly.jpg\" /></td><td valign=\"top\">Confirming w hat health professionals have long suspected, a new study published in the journal PLOS Medicine provides some of the strongest evidence yet that obesity is indeed a cause of vitamin D deficiency. &# 10; The large study was a collaborative effort between U.S...</td></tr></table>"], "title": ["Obesity causes vitamin-D deficiency: Research"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "med oozie_score": 313}},{"_index":"feed","_type":"article","_id":"osvu1IlkSwa9yL566YoQuQ","_score":1.0, "_source" : {"source": ["http://www.naturalnews.com/040627_Judge_Napolitano_Eric_Holder_freedom_of_the_ press.html"], "link": ["http://www.naturalnews.com/040627_Judge_Napolitano_Eric_Holder_freedom_of_the_press.html"], "description": ["<table><tr><td><img src=\"http://www.naturalnews.com/gallery/300X250/C oncepts/Extra-Liar-Newspaper-Headline.jpg\" /></td><td valign=\"top\">Terrorism, and the threat of new attacks, dominated U.S. domestic policy and national security strategy throughout the Bush Administr ation, but my, how times have changed: Despite the recent terrorist bombings of the Boston Marathon April 19, President Barack Obama appears...</td></tr></table>"], "title": ["Judge Napolitano: Obama mor e threatened by journalism than terrorism"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 34}},{"_index":"feed","_type":"article","_id":"0XfVTXImTWGwQ1Ko13Q9hg","_score":1.0, "_source " : {"source": ["http://www.naturalnews.com/040637_mental_illness_depression_women.html"], "link": ["http://www.naturalnews.com/040637_mental_illness_depression_women.html"], "description": ["<table><tr> <td><img src=\"http://www.naturalnews.com/gallery/300X250/Cancer/Poor-Women-Breast-Cancer.jpg\" /></td><td valign=\"top\">For reasons that are still largely unclear, women are much more likely than men t o develop some form of mental illness during their lives, whether it be depression, schizophrenia, or simple anxiety, according to a new study. Based on an analysis of 12 large-scale epidemiological...</ td></tr></table>"], "title": ["Women are 40 percent more likely to develop mental illness than men, study concludes"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 434}},{"_index":"fe ed","_type":"article","_id":"8L699AbUTtmlrnlSJlmzhw","_score":1.0, "_source" : {"source": ["http://www.naturalnews.com/040624_cancer_industry_documentary_lies.html"], "link": ["http://www.naturalnews.com /040624_cancer_industry_documentary_lies.html"], "description": ["<table><tr><td><img src=\"http://www.naturalnews.com/gallery/300x250/Programs/Cut-Poison-Burn.jpg\" /></td><td valign=\"top\">The stunnin g, jaw-dropping and tearfully devastating true story of the conventional cancer industry is unleashed in a new documentary called \"Cut, Poison, Burn.\" While celebrities like Michael Douglas are grabbin g headlines by promoting the dangerous myths and false...</td></tr></table>"], "title": ["Profiteering cancer industry ripped wide open by explosive documentary 'Cut, Poison, Burn' - watch preview here"] , "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 187}}]}}
这是我将 request.json() 返回的结果写入 txt 文件时得到的结果:
'{"source": ["http://www.naturalnews.com/040640_front_groups_food_industry_processed.html"], "link": ["http://www.naturalnews.com/040640_front_groups_food_industry_processed.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Logos/Pepsi-Logo.jpg\\" /></td><td valign=\\"top\\">Some say it\'s the best public relations that money can buy, because when you can\'t refute the truth about an issue, the next-best thing to do is stack the deck in your favor. The third edition of a report released last month by the International Food Information Council...</td></tr></table>"], "title": ["Food industry front groups exposed in new report: Monsanto, Coke, Pepsi and more"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 350}'
'{"source": ["http://www.naturalnews.com/040639_Obamacare_insurance_premiums_individual_mandate.html"], "link": ["http://www.naturalnews.com/040639_Obamacare_insurance_premiums_individual_mandate.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300x250/celebrities/Barack-Obama-Portrait.jpg\\" /></td><td valign=\\"top\\">The scramble is on to bring the logistical framework for Obamacare into full fruition before its inaugural arrival in 2014. But as legislators and program architects dig down into the nitty-gritty of what the \\"tax\\" will actually entail in practicality, it is becoming...</td></tr></table>"], "title": ["Obamacare will collapse under the weight of rising premiums"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 121}'
'{"source": ["http://www.naturalnews.com/040638_Garcinia_cambogia_weight_loss_obestity.html"], "link": ["http://www.naturalnews.com/040638_Garcinia_cambogia_weight_loss_obestity.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Men/Belly-Fat.jpg\\" /></td><td valign=\\"top\\">With celeb Dr. Oz advocating its use, Garcinia Cambogia (also known as Malabar tamarind, gambooge and brindleberry), has gained notoriety as a fast-acting and cheap fat buster that both suppresses appetite and prevents fat from being made. For generations, this fruit...</td></tr></table>"], "title": ["Does Garcinia cambogia extract really help with weight loss?"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 120}'
'{"source": ["http://www.naturalnews.com/040637_mental_illness_depression_women.html"], "link": ["http://www.naturalnews.com/040637_mental_illness_depression_women.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Cancer/Poor-Women-Breast-Cancer.jpg\\" /></td><td valign=\\"top\\">For reasons that are still largely unclear, women are much more likely than men to develop some form of mental illness during their lives, whether it be depression, schizophrenia, or simple anxiety, according to a new study. Based on an analysis of 12 large-scale epidemiological...</td></tr></table>"], "title": ["Women are 40 percent more likely to develop mental illness than men, study concludes"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 468}'
'{"source": ["http://www.naturalnews.com/040636_IRS_scandal_conservative_groups_Obama_Administration.html"], "link": ["http://www.naturalnews.com/040636_IRS_scandal_conservative_groups_Obama_Administration.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Money/IRS-Building-Revenue-Taxes-Money.jpg\\" /></td><td valign=\\"top\\">Officials with the Internal Revenue Service (IRS) have admitted that the agency inappropriately targeted conservative groups seeking legal tax-exemption status in the years and months leading up to the 2012 election. Those same officials have apologized for the targeting...</td></tr></table>"], "title": ["Claim: IRS still targeting conservative groups, even after promising the intimidation already stopped"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 12}'
'{"source": ["http://www.naturalnews.com/040635_cooling_foods_summer_eating_whole.html"], "link": ["http://www.naturalnews.com/040635_cooling_foods_summer_eating_whole.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Women/Woman-Summersault-Grass-Fitness-Play.jpg\\" /></td><td valign=\\"top\\">As we enter into the dog days of summer, it\'s easy to keep cool with specific foods and herbs under our belt. Using the wisdom of Traditional Chinese Medicine (TCM), we can remain balanced, calm and energetic as the mercury rises. Particular suggestions border on simple...</td></tr></table>"], "title": ["Stay cool this summer with natural medicine and herbal remedies"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 495}'
'{"source": ["http://www.naturalnews.com/040634_mental_health_President_Obama_Big_Pharma.html"], "link": ["http://www.naturalnews.com/040634_mental_health_President_Obama_Big_Pharma.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Concepts/Man-Hat-Brain-Concept.jpg\\" /></td><td valign=\\"top\\">President Obama gave psychiatrists and pharmaceutical companies the keys to the kingdom during his keynote speech at the White House Conference on Mental Health this week. Celebrated as a hero to the shamed and downtrodden, Obama played the part well as he subtly...</td></tr></table>"], "title": ["Obama keynote speech deals death blow to mental health, delivers millions into the hands of big pharma"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 280}'
'{"source": ["http://www.naturalnews.com/040633_Bug_Eating_Festival_insects_survival_foods.html"], "link": ["http://www.naturalnews.com/040633_Bug_Eating_Festival_insects_survival_foods.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Women/Party-Girls-Fun.jpg\\" /></td><td valign=\\"top\\">Are people in Austin so hungry they are eating bugs? \\"Well, it does help if you come to the party having skipped lunch,\\" says Marjory Wildcraft, the host and creator 6th Annual Bug Eating Festival which will be held on Saturday June 29, 2013 at Zilker Park in Austin...</td></tr></table>"], "title": ["6th Annual Bug Eating Festival"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 191}'
'{"source": ["http://www.naturalnews.com/040632_C-sections_obesity_childbirth.html"], "link": ["http://www.naturalnews.com/040632_C-sections_obesity_childbirth.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Medical/Woman-Giving-Birth-Delivering-Baby-Nurses-Doctors-Hospital.jpg\\" /></td><td valign=\\"top\\">New research out of the U.K. sheds light on yet another possible cause of widespread childhood obesity. Based on an analysis involving more than 10,000 British babies, roughly 9 percent of whom were born via C-section, researchers found that babies delivered the alternate...</td></tr></table>"], "title": ["C-sections lead to obese kids, study finds"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 64}'
'{"source": ["http://www.naturalnews.com/040631_farmed_salmon_GMO_sustainable_fishing.html"], "link": ["http://www.naturalnews.com/040631_farmed_salmon_GMO_sustainable_fishing.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Food/Salmon-Raw.jpg\\" /></td><td valign=\\"top\\">Equally as menacing as the potential release of genetically-modified (GM) salmon into the wild, factory fish farms are a modern scourge responsible for killing off droves of native fish species all around the world. And unless immediate action is taken to address this...</td></tr></table>"], "title": ["Fish farming killing off native species; boycott farmed salmon before it\'s too late"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 281}'
'{"source": ["http://www.naturalnews.com/040630_egg_whites_blood_pressure_peptides.html"], "link": ["http://www.naturalnews.com/040630_egg_whites_blood_pressure_peptides.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Food/Brown-Eggs-On-White.jpg\\" /></td><td valign=\\"top\\">Considering that eggs contain all the nutrients needed to develop healthy chicks, it is unsurprising that studies into their numerous health benefits for humans abound. Eating more eggs has, for instance, been repeatedly linked to reduced LDL cholesterol, a lowered risk...</td></tr></table>"], "title": ["Peptide found in egg whites can lower blood pressure, say researchers"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 118}'
'{"source": ["http://www.naturalnews.com/040629_obesity_vitamin_D_deficiency_exercise.html"], "link": ["http://www.naturalnews.com/040629_obesity_vitamin_D_deficiency_exercise.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Men/Big-Fat-Hairy-Obese-Belly.jpg\\" /></td><td valign=\\"top\\">Confirming what health professionals have long suspected, a new study published in the journal PLOS Medicine provides some of the strongest evidence yet that obesity is indeed a cause of vitamin D deficiency. The large study was a collaborative effort between U.S...</td></tr></table>"], "title": ["Obesity causes vitamin-D deficiency: Research"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 395}'
'{"source": ["http://www.naturalnews.com/040628_calf_exercises_soleus_stretch_lower_body_workouts.html"], "link": ["http://www.naturalnews.com/040628_calf_exercises_soleus_stretch_lower_body_workouts.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Exercise/Running-Shoes-Fitness-Legs-Calves-Muscles.jpg\\" /></td><td valign=\\"top\\">Building killer calves is more complicated than people think. Most exercisers do a bunch of standing calf exercises like standing calf raises, sled hack calf raises, donkey raises, and calf presses to bulk up not realizing that their entire workout is only targeting...</td></tr></table>"], "title": ["Calf exercises: Sit down to build yourself up"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 469}'
'{"source": ["http://www.naturalnews.com/040627_Judge_Napolitano_Eric_Holder_freedom_of_the_press.html"], "link": ["http://www.naturalnews.com/040627_Judge_Napolitano_Eric_Holder_freedom_of_the_press.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Concepts/Extra-Liar-Newspaper-Headline.jpg\\" /></td><td valign=\\"top\\">Terrorism, and the threat of new attacks, dominated U.S. domestic policy and national security strategy throughout the Bush Administration, but my, how times have changed: Despite the recent terrorist bombings of the Boston Marathon April 19, President Barack Obama appears...</td></tr></table>"], "title": ["Judge Napolitano: Obama more threatened by journalism than terrorism"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 96}'
'{"source": ["http://www.naturalnews.com/040626_Hopewood_children_natural_living_organic_foods.html"], "link": ["http://www.naturalnews.com/040626_Hopewood_children_natural_living_organic_foods.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Children/Kids-Children-Play-Outside-Happy-Exercise.jpg\\" /></td><td valign=\\"top\\">In 1942, the founder of the Natural Health Society of Australia, Leslie Owen Bailey, began a social experiment: He chose to adopt 85 children whose parents were unable to provide for them. The children\'s residence became the sprawling Hopewood House in New South Wales...</td></tr></table>"], "title": ["Honoring nature: The lesson of the Hopewood children"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 445}'
'{"source": ["http://www.naturalnews.com/040625_lawsuit_Monsanto_genetic_pollution.html"], "link": ["http://www.naturalnews.com/040625_lawsuit_Monsanto_genetic_pollution.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Farming/Man-Farmer-Wheat-Crop-Field-Clouds-Sky.jpg\\" /></td><td valign=\\"top\\">The next wave of farmer backlash against Monsanto has just been unleashed by Ernest Barnes, a wheat farmer in Morton County, Kansas. He filed suit this week in the U.S. District Court in Wichita, Kansas, alleging that Monsanto\'s genetic pollution has financially damaged...</td></tr></table>"], "title": ["It\'s on! Farmers begin suing Monsanto over genetic pollution of wheat crops"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 311}'
'{"source": ["http://www.naturalnews.com/040624_cancer_industry_documentary_lies.html"], "link": ["http://www.naturalnews.com/040624_cancer_industry_documentary_lies.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300x250/Programs/Cut-Poison-Burn.jpg\\" /></td><td valign=\\"top\\">The stunning, jaw-dropping and tearfully devastating true story of the conventional cancer industry is unleashed in a new documentary called \\"Cut, Poison, Burn.\\" While celebrities like Michael Douglas are grabbing headlines by promoting the dangerous myths and false...</td></tr></table>"], "title": ["Profiteering cancer industry ripped wide open by explosive documentary \'Cut, Poison, Burn\' - watch preview here"], "published": ["Wed, 5 Jun 2013 00:00:00 CST"], "medoozie_score": 216}'
'{"source": ["http://www.naturalnews.com/040623_Morninglane_Dairy_Vernon_Hershberger_food_freedom.html"], "link": ["http://www.naturalnews.com/040623_Morninglane_Dairy_Vernon_Hershberger_food_freedom.html"], "description": ["<table><tr><td><img src=\\"http://www.naturalnews.com/gallery/300X250/Farming/Farmer-Crops.jpg\\" /></td><td valign=\\"top\\">There is a war being waged against real food - no, not the heavily-processed, chemical-laden garbage that fills the aisles of most major supermarkets today, but actual wholesome food grown on clean, family-scale farms across the U.S. And the upcoming documentary Let...</td></tr></table>"], "title": ["\'Let Them Eat Grass\' documentary to expose massive government tyranny against small-scale farmers producing real food"], "published": ["Tue, 4 Jun 2013 00:00:00 CST"], "medoozie_score": 211}'
{u'hits': {u'hits': [{u'_score': 0.32461247, u'_type': u'article', u'_id': u'yBqM5NSoTDCAeXo2YRO1hQ', u'_source': {u'description': [u'<table><tr><td><img src="http://www.naturalnews.com/gallery/300X250/Concepts/Man-Hat-Brain-Concept.jpg" /></td><td valign="top">President Obama gave psychiatrists and pharmaceutical companies the keys to the kingdom during his keynote speech at the White House Conference on Mental Health this week. Celebrated as a hero to the shamed and downtrodden, Obama played the part well as he subtly...</td></tr></table>'], u'title': [u'Obama keynote speech deals death blow to mental health, delivers millions into the hands of big pharma'], u'source': [u'http://www.naturalnews.com/040634_mental_health_President_Obama_Big_Pharma.html'], u'link': [u'http://www.naturalnews.com/040634_mental_health_President_Obama_Big_Pharma.html'], u'medoozie_score': 93, u'published': [u'Wed, 5 Jun 2013 00:00:00 CST']}, u'_index': u'feed'}, {u'_score': 0.16524655, u'_type': u'article', u'_id': u'Grh9KUDVQvSs7oRUjzOG9A', u'_source': {u'description': [u'<table><tr><td><img src="http://www.naturalnews.com/gallery/300X250/Food/Brown-Eggs-On-White.jpg" /></td><td valign="top">Considering that eggs contain all the nutrients needed to develop healthy chicks, it is unsurprising that studies into their numerous health benefits for humans abound. Eating more eggs has, for instance, been repeatedly linked to reduced LDL cholesterol, a lowered risk...</td></tr></table>'], u'title': [u'Peptide found in egg whites can lower blood pressure, say researchers'], u'source': [u'http://www.naturalnews.com/040630_egg_whites_blood_pressure_peptides.html'], u'link': [u'http://www.naturalnews.com/040630_egg_whites_blood_pressure_peptides.html'], u'medoozie_score': 262, u'published': [u'Wed, 5 Jun 2013 00:00:00 CST']}, u'_index': u'feed'}, {u'_score': 0.16524655, u'_type': u'article', u'_id': u'6OfIM7G9Rke-TD3N6bI4Ow', u'_source': {u'description': [u'<table><tr><td><img src="http://www.naturalnews.com/gallery/300X250/Men/Big-Fat-Hairy-Obese-Belly.jpg" /></td><td valign="top">Confirming what health professionals have long suspected, a new study published in the journal PLOS Medicine provides some of the strongest evidence yet that obesity is indeed a cause of vitamin D deficiency. The large study was a collaborative effort between U.S...</td></tr></table>'], u'title': [u'Obesity causes vitamin-D deficiency: Research'], u'source': [u'http://www.naturalnews.com/040629_obesity_vitamin_D_deficiency_exercise.html'], u'link': [u'http://www.naturalnews.com/040629_obesity_vitamin_D_deficiency_exercise.html'], u'medoozie_score': 313, u'published': [u'Wed, 5 Jun 2013 00:00:00 CST']}, u'_index': u'feed'}, {u'_score': 0.15372275, u'_type': u'article', u'_id': u'RBV1P_lXStKAHeaNi-q9Bg', u'_source': {u'description': [u'<table><tr><td><img src="http://www.naturalnews.com/gallery/300X250/Children/Kids-Children-Play-Outside-Happy-Exercise.jpg" /></td><td valign="top">In 1942, the founder of the Natural Health Society of Australia, Leslie Owen Bailey, began a social experiment: He chose to adopt 85 children whose parents were unable to provide for them. The children\'s residence became the sprawling Hopewood House in New South Wales...</td></tr></table>'], u'title': [u'Honoring nature: The lesson of the Hopewood children'], u'source': [u'http://www.naturalnews.com/040626_Hopewood_children_natural_living_organic_foods.html'], u'link': [u'http://www.naturalnews.com/040626_Hopewood_children_natural_living_organic_foods.html'], u'medoozie_score': 187, u'published': [u'Wed, 5 Jun 2013 00:00:00 CST']}, u'_index': u'feed'}], u'total': 4, u'max_score': 0.32461247}, u'_shards': {u'successful': 5, u'failed': 0, u'total': 5}, u'took': 66, u'timed_out': False}
如何让 json.loads(json-string) 返回字典而不是字符串或字符串列表?如果这不可能,那么将列表中的每个字符串转换为字典的好方法是什么?
事实证明 r.json() 函数从未被破坏。我只是不知道如何遍历结果。
下面是我如何修改我的代码以便我可以遍历它...
r = requests.get('http://localhost:9200/feed/_search?q=' + query)
results = r.json()
for result in results['hits']['hits']:
print(result['_source']['title'])
这是我正在解码的 json 的较小示例...
最佳答案
事实证明 r.json() 函数从未被破坏。我只是不知道如何遍历结果。
下面是我如何修改我的代码以便我可以遍历它...
r = requests.get('http://localhost:9200/feed/_search?q=' + query)
results = r.json()
for result in results['hits']['hits']:
print(result['_source']['title'])
这是我正在解码的 json 的较小示例...
关于python - 如何让 json.loads(json-string) 返回字典而不是字符串或字符串列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16941601/
我正在 div 中加载一个 php 页面,该页面采用发布的变量来显示正确的内容。它的工作原理是这样的: $(".mainArea").load("page.php", {'folder': 'a'})
我是 AWS 新手。我开始学习 ALB 和 NLB。我知道 ALB 在第 7 层协议(protocol)中工作,而 NLB 在第 4 层协议(protocol)中工作。 谁能解释一下ALB和NLB的实
这是来自 this Article . filter(loaded => !loaded) 有什么作用?我没有在任何地方看到该变量的定义。 我明白这个方法的目的是什么,只是不是那一行。 canActi
我应该在 Constructor 还是 FormLoad() 中加载子表单? 我有一些代码调用在控件中嵌入表单的自定义类。我最初是在 Constructor 之外声明我的子窗体,然后在 FormLoa
目录 1、图解 2、json.loads()用法 3、json.load()用法 4、此外还有一种json.dumps 语法
我正在使用 PhoneGap 为 iPad 编写应用程序,我想在不触发 Safari 或使用 ChildBrowser 等内部 Web 浏览器的情况下加载外部 URL。 我正在使用 PhoneGap
人们经常在他们的(与优化和性能相关的)问题和答案中谈论“重载”。 我试图在典型服务器上的常规 Web 应用程序的上下文中量化这一点(以 SO 及其相当小的基础设施为例),假设它们立即返回(以简化和提高
有人可以写这段代码吗: this.Loaded += (s, e) => this.loaded = true; 分成几行代码以便我可以追溯其含义? 在我的代码示例中没有 s 或 e 吗? 最佳答案
我正在使用 jQuery 的 .load()方法和Loading Page Fragments 。以下是我当前的代码: $("#submit").click(function() { $("#
我想实现的是,当单击图像时,在该图像所在的 div 中,加载了一个包含来自另一个 .html 的其他内容的 div,但我无法完成。 如果我这样做,下面的代码将完美运行: $('#windows_lin
我使用 qt 开发了一个 c++ 库。在本文中,我使用 QSqlDatabase 从 SQLite 数据库中查询信息。注意:我的库在 qt 桌面应用程序中运行良好(我在 Linux 上开发)。 现在我
演示:http://jsfiddle.net/FyrRm/1/ 当我们向下滚动时,您会注意到...在滚动到文章标题到 之后我正在展示一个共享小部件。我正在使用 $(window).on("load"
我在 html(PC) 中使用的图像正确加载,我使用了 img 标签。我已将此文件连同图像一起保存并发送到我的手机,但它不会加载到手机上。我对图像大小或任何东西没有任何问题。我认为它与图像位置有关。
我将 .load() 广泛用于 AJAX 内容。很棒,但如果它做得更多一点,我会喜欢它: 如果为了响应用户操作,我多次调用同一个 div 上的 .load(),我可能会在 div 中得到错误的数据。当
我知道很多方法需要调用它的父类(super class)方法,有些方法不需要, 我正在寻找关于方法调配的东西。它在加载方法中初始化,并且在教程中没有[super load]。 我想知道是不是错了,还是
几个月来,我一直在使用pyGame 2.0.1。今天,我升级到最新版本(2.1.2)后,在尝试加载音频文件时开始出现以下错误:。到目前为止我尝试过的东西:。我使用的是Windows 10、Python
我有一个完整的 angular 应用程序,它使用预先加载。 我想将其转换为延迟加载,但是因为我对所有路线都有保护,而且所有路线都是到一条 protected 主路线的子路线,我不知道是否可以做到这一点
我有一个 React 应用程序,它在 useEffect 中调用我的 API,返回一个用作 imy 图像 src 的 URL 列表。 我正在使用 react-loader-spinner 在加载图像时
我正在使用 Slick.js 逐步加载我的图像我注意到有些图像要么部分加载,要么根本没有加载。 例如,在this site上,有两个画廊:建筑和设计(在导航中)。当用户单击任一图像时,他们会看到该图库
我在我的一个项目中收到此警告。这在调用我的后端 api 时会导致问题,因为它调用了 api 两次。我已经尝试过之前在论坛上发布的关于相同查询的解决方案,但我无法解决这个问题。如果有人能帮助我解决这个问
我是一名优秀的程序员,十分优秀!