我可以通过以下方式从CountryInfo中提取一个国家的信息:
from countryinfo import CountryInfo
country = CountryInfo('India')
country.info()
以及
country.population()
然而,我有一系列的国家,比如
country = ['Afganistan', 'India', 'Zimbabwe']
我想遍历库CountryInfo,根据country数组得到每个国家的人口,并将其保存在数组中
Tags:
您要求提供一个“数组”(您是指列表吗?),但将数据保存在字典中更有意义:
这给了你
然后你可以做个例子
根据我的假设并理解您的答案,这里是工作示例代码
相关问题 更多 >
编程相关推荐