示例#1
0
def get_country_population_and_continent(country: str, ) -> Tuple[int, str]:
    try:
        country_translated = (country if country
                              not in COUNTRIES_TRANSLATE_TO_COUNTRYINFO.keys()
                              else COUNTRIES_TRANSLATE_TO_COUNTRYINFO[country])

        country_translated_info = CountryInfo(country_translated)
        population = country_translated_info.population()
        continent = country_translated_info.region()
    except KeyError:
        population, continent = -1, FILLNA

    return population, continent
def country_info(country_name):
    d = []
    country = CountryInfo(country_name)
    d.append(["name", country.name().capitalize()])
    d.append(["capital", country.capital().capitalize()])
    d.append(["region", country.region().capitalize()])
    d.append(["currency", country.currencies()])
    d.append(["area", country.area()])
    d.append(["population", country.population()])
    d.append(["languages", country.languages()])
    d.append(["borders", country.borders()])
    d.append(["calling code", country.calling_codes()])
    d.append(["lat/long", country.capital_latlng()])
    d.append(["code", country.iso(2)])
    return d
def get_continent_by_country(country):
    country = CountryInfo(country)
    return country.region()
示例#4
0
    print(timezones, end=', ')

country_area = country.area()
print(f'\n\nCountry Area:\n{country_area}')

country_borders = country.borders()
print('\nBorders:')
for border in country_borders:
    print(border, end=', ')

calling_codes = country.calling_codes()
print('\n\nCall Code:')
for call_code in calling_codes:
    print(call_code)

country_region = country.region()
print(f'\nRegion:\n{country_region}')

sub_region = country.subregion()
print(f'\nSub-Region:\n{sub_region}')

country_population = country.population()
print(f'\nPopulation:\n{country_population}')

country_states = country.provinces()
print('\nStates/Provinces:')
for states in country_states:
    print(states, end=', ')

about_country = country.wiki()