我正在尝试将我的数据中的国家/地区与 python 内置的 pycountry 包进行匹配。运行后出现此错误
raise AttributeError
属性错误
countries_lookup = {}
countries = list(pycountry.countries)
for country in countries:
countries_lookup[country.alpha2]=country.name
country_names = list(countries_lookup.values())
country_names = [country.lower() for country in country_names]
country_names = set(country_names)
应该是什么问题?
请您参考如下方法:
只是一个打字错误:
countries_lookup[country.alpha_2]=country.name
#-----------------------------^
