babel_measures.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:talks-python-i18n_l10n 作者: zgoda-mobica 项目源码 文件源码
def units_formating():
    print('Formating values in units')
    values = (
        (12.4, 'area-square-meter'),
        (7.7, 'consumption-liter-per-100kilometers'),
        (1017, 'pressure-hectopascal'),
        (9, 'duration-century'),
        (11, 'energy-kilowatt-hour'),
        (2, 'volume-pint'),
    )
    for (name, symbol, params) in LOCALES:
        locale = Locale(*params)
        args = [name]
        for (value, unit) in values:
            val_long = format_unit(value, unit, 'long', locale=locale)
            short_name = get_unit_name(unit, 'short', locale=locale) 
            args.append('{0} ({1})'.format(val_long, short_name))
        print('\nin {0}: {1} - {2} - {3} - {4} - {5} - {6}'.format(*args))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号