コード例 #1
0
ファイル: general.py プロジェクト: CoderN-P/Country-Bot
    async def states(self, ctx, *, country):
        data = await country_filter(country, ctx)
        if data is None:
            return

        country = data["name"]
        country1 = CountryInfo(country)

        result = country1.provinces()

        for i, x in enumerate(result):
            result[i] = "`" + x + "`"

        result1 = " |".join(result)

        result2 = re.sub(r"(?<=[|])(?=[^\s])", r" ", result1)

        embed = discord.Embed(
            title="States of " + country,
            description="**{result2}**".format(result2=result2),
            color=0xFF5733,
        )

        result4 = coco.convert(names=country, to="ISO2")
        embed.set_thumbnail(
            url=f"https://flagcdn.com/w80/{result4.lower()}.jpg")

        embed.set_footer(
            text="Requested by: {name}".format(name=ctx.author),
            icon_url=ctx.author.avatar_url,
        )

        await ctx.send(embed=embed)
コード例 #2
0
ファイル: viewsets.py プロジェクト: fmeurou/djangophysics
 def provinces(self, request, alpha_2):
     """
     Send provinces for a specific country
     """
     try:
         c = CountryInfo(alpha_2)
         return Response(c.provinces(), content_type="application/json")
     except KeyError:
         return Response("Unknown country or no info for this country",
                         status=HTTP_404_NOT_FOUND)
コード例 #3
0
def get_provinces_by_country(country):
    country = CountryInfo(country)
    return country.provinces()
コード例 #4
0
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()

country_map = country.capital_latlng()
map = folium.Map(location=(country_map))
print(
    f'\n\nCheck your directory for the map of  {user}, named: (mylocation.html)'
)
map.save("mylocation.html")

about_country = country.wiki()