当前位置: 首页>>代码示例>>Python>>正文


Python localization.format_money函数代码示例

本文整理汇总了Python中moneyed.localization.format_money函数的典型用法代码示例。如果您正苦于以下问题:Python format_money函数的具体用法?Python format_money怎么用?Python format_money使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了format_money函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __unicode__

    def __unicode__(self):
        kwargs = {'money': self, 'decimal_places': DECIMAL_PLACES}
        if self.is_localized:
            locale = get_current_locale()
            if locale:
                kwargs['locale'] = locale

        return format_money(**kwargs)
开发者ID:django4life,项目名称:django-money,代码行数:8,代码来源:money.py

示例2: format_money_remove_aud

def format_money_remove_aud(self, **kwargs):
    """
    Monkey patch money.Money.format so that the default currency (AUD) isn't displayed
    when calling Money.format()

    @author: Alex Hayes <[email protected]>
    """
    return format_money(self, **kwargs).replace('A$', '$')
开发者ID:NavyaEV,项目名称:instagram,代码行数:8,代码来源:monkeypatches.py

示例3: moneyformat

def moneyformat(value, currency = 'PLN', decimal_pos = 2, locale = None):
    locale = get_money_locale(locale)

    if isinstance(value, Money):
        pass
    else:
        value = Money(value, currency = get_currency(str(currency)))

    return format_money(value, decimal_places = decimal_pos, locale = locale)
开发者ID:integree,项目名称:django-congo,代码行数:9,代码来源:formats.py

示例4: format_money

    def format_money(self, money):
        """Returns locale formated money

        :param money: Money
        :type money: moneyed.Money

        :rtype: unicode
        """
        return format_money(money, locale=self.locale())
开发者ID:SultanInUfa,项目名称:collective.cart.shopping,代码行数:9,代码来源:interface.py

示例5: test_format_money

 def test_format_money(self):
     # Two decimal places by default
     assert format_money(self.one_million_bucks) == 'US$1,000,000.00'
     # No decimal point without fractional part
     assert format_money(self.one_million_bucks, decimal_places=0) == 'US$1,000,000'
     # Locale format not included, should fallback to DEFAULT
     assert format_money(self.one_million_bucks, locale='es_ES') == 'US$1,000,000.00'
     # locale == pl_PL
     one_million_pln = Money('1000000', 'PLN')
     # Two decimal places by default
     assert format_money(one_million_pln, locale='pl_PL') == '1 000 000,00 zł'
     assert format_money(self.one_million_bucks, locale='pl_PL') == 'US$1 000 000,00'
     # No decimal point without fractional part
     assert format_money(one_million_pln, locale='pl_PL',
                         decimal_places=0) == '1 000 000 zł'
开发者ID:limist,项目名称:py-moneyed,代码行数:15,代码来源:test_moneyed_classes.py

示例6: __str__

 def __str__(self):
     from moneyed.localization import format_money
     return format_money(self)
开发者ID:fizista,项目名称:py-moneyed,代码行数:3,代码来源:classes.py

示例7: currency

def currency(value):
    return format_money(value, locale=DJANGO)
开发者ID:django,项目名称:djangoproject.com,代码行数:2,代码来源:foundation.py

示例8: test_format_money

 def test_format_money(self):
     # Two decimal places by default
     assert format_money(self.one_million_bucks) == 'US$1,000,000.00'
     # No decimal point without fractional part
     assert format_money(self.one_million_bucks, decimal_places=0) == 'US$1,000,000'
开发者ID:devlocal,项目名称:py-moneyed,代码行数:5,代码来源:test_moneyed_classes.py

示例9: test_format_money

    def test_format_money(self):
        # Two decimal places by default
        assert format_money(self.one_million_bucks) == 'US$1,000,000.00'
        # No decimal point without fractional part
        assert format_money(self.one_million_bucks, decimal_places=0) == 'US$1,000,000'
        # locale == pl_PL
        one_million_pln = Money('1000000', 'PLN')
        # Two decimal places by default
        assert format_money(one_million_pln, locale='pl_PL') == '1 000 000,00 zł'

        # overriden sign/format locale display default sign with locale group parameter
        assert format_money(self.one_million_bucks, locale='pl_PL') == 'US$1 000 000,00'
        # non overriden sign/format locale display default money sign with default group parameter
        assert format_money(self.one_million_bucks, locale='fr_FR') == 'US$1,000,000.00'

        # No decimal point without fractional part
        assert format_money(one_million_pln, locale='pl_PL', decimal_places=0) == '1 000 000 zł'

        # add different sign for money USD in locale pl_PL
        _sign('pl_PL', moneyed.USD, prefix='$')
        assert format_money(self.one_million_bucks, locale='pl_PL') == '$1 000 000,00'

        # default locale display correct money sign with default group parameter
        assert format_money(self.one_million_euros) == '1,000,000.00 €'
        # non overriden sign/format locale display default money sign with default group parameter
        assert format_money(self.one_million_euros, locale='fr_FR') == '1,000,000.00 €'
        # overriden sign/locale locale display default money sign with locale group parameter
        assert format_money(self.one_million_euros, locale='en_US') == '1,000,000.00 €'

        # add format for fr_FR locale
        _format("fr_FR", group_size=3, group_separator=" ", decimal_point=",",
                positive_sign="", trailing_positive_sign="",
                negative_sign="-", trailing_negative_sign="",
                rounding_method=ROUND_HALF_EVEN)
        # overriden format locale display correct sign with locale group parameter
        assert format_money(self.one_million_euros, locale='fr_FR') == '1 000 000,00 €'
开发者ID:GuillaumeCisco,项目名称:py-moneyed,代码行数:36,代码来源:test_moneyed_classes.py


注:本文中的moneyed.localization.format_money函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。