本文整理汇总了Python中pycountry.currencies方法的典型用法代码示例。如果您正苦于以下问题:Python pycountry.currencies方法的具体用法?Python pycountry.currencies怎么用?Python pycountry.currencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycountry
的用法示例。
在下文中一共展示了pycountry.currencies方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lookup
# 需要导入模块: import pycountry [as 别名]
# 或者: from pycountry import currencies [as 别名]
def test_lookup():
c = pycountry.countries
g = c.get(alpha_2='DE')
assert g == c.lookup('de')
assert g == c.lookup('DEU')
assert g == c.lookup('276')
assert g == c.lookup('germany')
assert g == c.lookup('Federal Republic of Germany')
# try a generated field
bqaq = pycountry.historic_countries.get(alpha_4='BQAQ')
assert bqaq == pycountry.historic_countries.lookup('atb')
german = pycountry.languages.get(alpha_2='de')
assert german == pycountry.languages.lookup('De')
euro = pycountry.currencies.get(alpha_3='EUR')
assert euro == pycountry.currencies.lookup('euro')
latin = pycountry.scripts.get(name='Latin')
assert latin == pycountry.scripts.lookup('latn')
al_bu = pycountry.subdivisions.get(code='AL-BU')
assert al_bu == pycountry.subdivisions.lookup('al-bu')
with pytest.raises(LookupError):
pycountry.countries.lookup('bogus country')
with pytest.raises(LookupError):
pycountry.countries.lookup(12345)
示例2: test_currencies
# 需要导入模块: import pycountry [as 别名]
# 或者: from pycountry import currencies [as 别名]
def test_currencies():
assert len(pycountry.currencies) == 170
assert isinstance(list(pycountry.currencies)[0], pycountry.db.Data)
argentine_peso = pycountry.currencies.get(alpha_3='ARS')
assert argentine_peso.alpha_3 == u'ARS'
assert argentine_peso.name == u'Argentine Peso'
assert argentine_peso.numeric == u'032'
示例3: test_lookup
# 需要导入模块: import pycountry [as 别名]
# 或者: from pycountry import currencies [as 别名]
def test_lookup():
c = pycountry.countries
g = c.get(alpha_2='DE')
assert g == c.get(alpha_2='de')
assert g == c.lookup('de')
assert g == c.lookup('DEU')
assert g == c.lookup('276')
assert g == c.lookup('germany')
assert g == c.lookup('Federal Republic of Germany')
# try a generated field
bqaq = pycountry.historic_countries.get(alpha_4='BQAQ')
assert bqaq == pycountry.historic_countries.lookup('atb')
german = pycountry.languages.get(alpha_2='de')
assert german == pycountry.languages.lookup('De')
euro = pycountry.currencies.get(alpha_3='EUR')
assert euro == pycountry.currencies.lookup('euro')
latin = pycountry.scripts.get(name='Latin')
assert latin == pycountry.scripts.lookup('latn')
al_bu = pycountry.subdivisions.get(code='AL-BU')
assert al_bu == pycountry.subdivisions.lookup('al-bu')
with pytest.raises(LookupError):
pycountry.countries.lookup('bogus country')
with pytest.raises(LookupError):
pycountry.countries.lookup(12345)
with pytest.raises(LookupError):
pycountry.countries.get(alpha_2=12345)
示例4: add_currencies
# 需要导入模块: import pycountry [as 别名]
# 或者: from pycountry import currencies [as 别名]
def add_currencies(apps, schema_editor):
""" Populates the currency table.
Data is pulled from pycountry. X currencies are not included given their limited use, and a desire
to limit the size of the options displayed in Django admin.
"""
Currency = apps.get_model('core', 'Currency')
Currency.objects.bulk_create(
[Currency(code=currency.alpha_3, name=currency.name) for currency in pycountry.currencies if
not currency.alpha_3.startswith('X')]
)