本文整理匯總了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')]
)