Esempio n. 1
0
 def languages(self, request, alpha_2):
     """
     Send languages for a specific country
     """
     try:
         c = CountryInfo(alpha_2)
         return Response(c.languages(), content_type="application/json")
     except KeyError:
         return Response("Unknown country or no info for this country",
                         status=HTTP_404_NOT_FOUND)
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
Esempio n. 3
0
#import the necessary module!
from countryinfo import CountryInfo

name = 'India'
country = CountryInfo(name)

data1 = country.alt_spellings()
print(data1)

data2 = country.capital()
print(data2)

data3 = country.currencies()
print(data3)

data4 = country.languages()
print(data4)

data5 = country.timezones()
print(data5)

data6 = country.area()
print(data6)

data7 = country.borders()
print(data7)

data8 = country.calling_codes()
print(data8)

data9 = country.wiki()
Esempio n. 4
0
country = CountryInfo(name)

country_name = country.alt_spellings()
print('\nName:')
for name in country_name:
    print(name, end=', ')

country_capital = country.capital()
print(f'\n\nCapital:\n{country_capital}')

country_currency = country.currencies()
print('\nCurrency:')
for currency in country_currency:
    print(currency, end=', ')

country_lang = country.languages()
print('\n\nLanguages:')
for languages in country_lang:
    print(languages, end=', ')

country_timezone = country.timezones()
print('\n\nTime-Zone:')
for timezones in country_timezone:
    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: