|
- [
- {
- "Country Name": "Arab World",
- "Country Code": "ARB",
- "Year": "2010",
- "Value": "357868000"
- },
- {
- "Country Name": "Caribbean small states",
- "Country Code": "CSS",
- "Year": "2010",
- "Value": "6880000"
- },
- {
- "Country Name": "East Asia & Pacific (all income levels)",
- "Country Code": "EAS",
- "Year": "2010",
- "Value": "2201536674"
- },
- {
- "Country Name": "East Asia & Pacific (developing only)",
- "Country Code": "EAP",
- "Year": "2010",
- "Value": "1961558757"
- },
- {
- "Country Name": "Euro area",
- "Country Code": "EMU",
- "Year": "2010",
- "Value": "331766000"
- },
- {
- "Country Name": "Europe & Central Asia (all income levels)",
- "Country Code": "ECS",
- "Year": "2010",
- "Value": "890424544"
- },
- {
- "Country Name": "Europe & Central Asia (developing only)",
- "Country Code": "ECA",
- "Year": "2010",
- "Value": "405204000"
- },
- {
- "Country Name": "European Union",
- "Country Code": "EUU",
- "Year": "2010",
- "Value": "502125000"
- },
- {
- "Country Name": "Heavily indebted poor countries (HIPC)",
- "Country Code": "HPC",
- "Year": "2010",
- "Value": "635663000"
- }
复制代码 上面这是population.py- from pygal_maps_world.maps import COUNTRIES
- def get_country_code(country_name):
- for code,name in COUNTRIES.items():
- if name==country_name:
- return code
- else:
- return None
复制代码 这是拿来查国家识别码的函数- import pygal
- import json
- from country_code import get_country_code
- filename=r'C:\Users\Administrator\Downloads\Downloading-Data-master\population_data.json'
- with open(filename) as f:
- f_data=json.load(f)
- for f_dict in f_data:
- if f_dict['Year']=='2010':
- country_name=f_dict['Country Name']
- population=int(float(f_dict['Value']))
- code=get_country_code(country_name)
- if code:
- print(code+':'+str(population))
- else:
- print('Error-'+country_name)
复制代码 这个代码主要就是查看国家识别码然后输入国家识别码 可是为什么有很多都是error的呢- Error-Arab World
- Error-Caribbean small states
- Error-East Asia & Pacific (all income levels)
- Error-East Asia & Pacific (developing only)
- Error-Euro area
- Error-Europe & Central Asia (all income levels)
- Error-Europe & Central Asia (developing only)
- Error-European Union
- Error-Heavily indebted poor countries (HIPC)
- Error-High income
- Error-High income: nonOECD
- Error-High income: OECD
- Error-Latin America & Caribbean (all income levels)
- Error-Latin America & Caribbean (developing only)
- Error-Least developed countries: UN classification
- Error-Low & middle income
- Error-Low income
- Error-Lower middle income
- Error-Middle East & North Africa (all income levels)
- Error-Middle East & North Africa (developing only)
- Error-Middle income
- Error-North America
- Error-OECD members
- Error-Other small states
- Error-Pacific island small states
- Error-Small states
- Error-South Asia
- Error-Sub-Saharan Africa (all income levels)
- Error-Sub-Saharan Africa (developing only)
- Error-Upper middle income
- Error-World
- Error-Afghanistan
- Error-Albania
- Error-Algeria
- Error-American Samoa
- ad:84864
- Error-Angola
- Error-Antigua and Barbuda
- Error-Argentina
- Error-Armenia
- Error-Aruba
- Error-Australia
- Error-Austria
- Error-Azerbaijan
- Error-Bahamas, The
- Error-Bahrain
- Error-Bangladesh
- Error-Barbados
- Error-Belarus
- Error-Belgium
- Error-Belize
- Error-Benin
- Error-Bermuda
- Error-Bhutan
- Error-Bolivia
- Error-Bosnia and Herzegovina
- Error-Botswana
- Error-Brazil
- Error-Brunei Darussalam
- Error-Bulgaria
- Error-Burkina Faso
- Error-Burundi
- Error-Cambodia
- Error-Cameroon
- Error-Canada
- Error-Cape Verde
- Error-Cayman Islands
- Error-Central African Republic
- Error-Chad
- Error-Channel Islands
- Error-Chile
- Error-China
- Error-Colombia
- Error-Comoros
- Error-Congo, Dem. Rep.
- Error-Congo, Rep.
- Error-Costa Rica
- Error-Cote d'Ivoire
- Error-Croatia
- Error-Cuba
- Error-Curacao
- Error-Cyprus
- Error-Czech Republic
- Error-Denmark
- Error-Djibouti
- Error-Dominica
- Error-Dominican Republic
- Error-Ecuador
- Error-Egypt, Arab Rep.
- Error-El Salvador
- Error-Equatorial Guinea
- Error-Eritrea
- Error-Estonia
- Error-Ethiopia
- Error-Faeroe Islands
- Error-Fiji
- Error-Finland
- Error-France
- Error-French Polynesia
- Error-Gabon
- Error-Gambia, The
- Error-Georgia
- Error-Germany
- Error-Ghana
- Error-Gibraltar
- Error-Greece
- Error-Greenland
- Error-Grenada
- Error-Guam
- Error-Guatemala
- Error-Guinea
- Error-Guinea-Bissau
- Error-Guyana
- Error-Haiti
- Error-Honduras
- Error-Hong Kong SAR, China
- Error-Hungary
- Error-Iceland
- Error-India
- Error-Indonesia
- Error-Iran, Islamic Rep.
- Error-Iraq
- Error-Ireland
- Error-Isle of Man
- Error-Israel
- Error-Italy
- Error-Jamaica
- Error-Japan
- Error-Jordan
- Error-Kazakhstan
- Error-Kenya
- Error-Kiribati
- Error-Korea, Dem. Rep.
- Error-Korea, Rep.
- Error-Kosovo
- Error-Kuwait
- Error-Kyrgyz Republic
- Error-Lao PDR
- Error-Latvia
- Error-Lebanon
- Error-Lesotho
- Error-Liberia
- Error-Libya
- Error-Liechtenstein
- Error-Lithuania
- Error-Luxembourg
- Error-Macao SAR, China
- Error-Macedonia, FYR
- Error-Madagascar
- Error-Malawi
- Error-Malaysia
- Error-Maldives
- Error-Mali
- Error-Malta
- Error-Marshall Islands
- Error-Mauritania
- Error-Mauritius
- Error-Mayotte
- Error-Mexico
- Error-Micronesia, Fed. Sts.
- Error-Moldova
- Error-Monaco
- Error-Mongolia
- Error-Montenegro
- Error-Morocco
- Error-Mozambique
- Error-Myanmar
- Error-Namibia
- Error-Nepal
- Error-Netherlands
- Error-New Caledonia
- Error-New Zealand
- Error-Nicaragua
- Error-Niger
- Error-Nigeria
- Error-Northern Mariana Islands
- Error-Norway
- Error-Oman
- Error-Pakistan
- Error-Palau
- Error-Panama
- Error-Papua New Guinea
- Error-Paraguay
- Error-Peru
- Error-Philippines
- Error-Poland
- Error-Portugal
- Error-Puerto Rico
- Error-Qatar
- Error-Romania
- Error-Russian Federation
- Error-Rwanda
- Error-Samoa
- Error-San Marino
- Error-Sao Tome and Principe
- Error-Saudi Arabia
- Error-Senegal
- Error-Serbia
- Error-Seychelles
- Error-Sierra Leone
- Error-Singapore
- Error-Sint Maarten (Dutch part)
- Error-Slovak Republic
- Error-Slovenia
- Error-Solomon Islands
- Error-Somalia
- Error-South Africa
- Error-Spain
- Error-Sri Lanka
- Error-St. Kitts and Nevis
- Error-St. Lucia
- Error-St. Martin (French part)
- Error-St. Vincent and the Grenadines
- Error-Sudan
- Error-Suriname
- Error-Swaziland
- Error-Sweden
- Error-Switzerland
- Error-Syrian Arab Republic
- Error-Tajikistan
- Error-Tanzania
- Error-Thailand
- Error-Timor-Leste
- Error-Togo
- Error-Tonga
- Error-Trinidad and Tobago
- Error-Tunisia
- Error-Turkey
- Error-Turkmenistan
- Error-Turks and Caicos Islands
- Error-Tuvalu
- Error-Uganda
- Error-Ukraine
- Error-United Arab Emirates
- Error-United Kingdom
- Error-United States
- Error-Uruguay
- Error-Uzbekistan
- Error-Vanuatu
- Error-Venezuela, RB
- Error-Vietnam
- Error-Virgin Islands (U.S.)
- Error-West Bank and Gaza
- Error-Yemen, Rep.
- Error-Zambia
- Error-Zimbabwe
复制代码
就是执行后变成这样 有人可以指导一下吗 这其实是《python从入门到实践》的第十六章的示范可是我真的看不懂
|
|