-4
[
{'Year': 1901,
  'Category': 'Chemistry',
  'Prize': 'The Nobel Prize in Chemistry 1901',
  'Motivation': '"in recognition of the extraordinary services he has rendered by the discovery of the laws of chemical dynamics and osmotic pressure in solutions"',
  'Prize Share': '1/1',
  'Laureate ID': 160,
  'Laureate Type': 'Individual',
  'Full Name': "Jacobus Henricus van 't Hoff",
  'Birth Date': '1852-08-30',
  'Birth City': 'Rotterdam',
  'Birth Country': 'Netherlands',
  'Sex': 'Male',
  'Organization Name': 'Berlin University',
  'Organization City': 'Berlin',
  'Organization Country': 'Germany',
  'Death Date': '1911-03-01',
  'Death City': 'Berlin',
  'Death Country': 'Germany'},
 {'Year': 1901,
  'Category': 'Literature',
  'Prize': 'The Nobel Prize in Literature 1901',
  'Motivation': '"in special recognition of his poetic composition, which gives evidence of lofty idealism, artistic perfection and a rare combination of the qualities of both heart and intellect"',
  'Prize Share': '1/1',
  'Laureate ID': 569,
  'Laureate Type': 'Individual',
  'Full Name': 'Sully Prudhomme',
  'Birth Date': '1839-03-16',
  'Birth City': 'Paris',
  'Birth Country': 'France',
  'Sex': 'Male',
  'Organization Name': '',
  'Organization City': '',
  'Organization Country': '',
  'Death Date': '1907-09-07',
  'Death City': 'Châtenay',
  'Death Country': 'France'}
]
4

1 回答 1

1

如果你想从给定的字典列表中查找有多少人属于同一个出生国家,你可以使用以下代码:

from collections import Counter

li = [each['Birth City'] for each in val if each['Birth City']]
print(dict(Counter(li)))

输出

{'Rotterdam': 1, 'Paris': 1}
于 2019-11-22T07:33:52.290 回答