Is there a package that maintains a list all currencies with symbols?

后端 未结 3 1331
广开言路
广开言路 2021-02-20 11:36

Is there a python package that provides list of all (or fairly complete) currencies with the symbols (like \"$\" for USD).

There are excellent pycount

3条回答
  •  自闭症患者
    2021-02-20 12:11

    import locale
    
    locales=('en_AG', 'en_AU.utf8', 'en_BW.utf8', 'en_CA.utf8',
        'en_DK.utf8', 'en_GB.utf8', 'en_HK.utf8', 'en_IE.utf8', 'en_IN', 'en_NG',
        'en_NZ.utf8', 'en_PH.utf8', 'en_SG.utf8', 'en_US.utf8', 'en_ZA.utf8',
        'en_ZW.utf8', 'ja_JP.utf8')
    for l in locales:
        locale.setlocale(locale.LC_ALL, l)
        conv=locale.localeconv()
        print('{int_curr_symbol} ==> {currency_symbol}'.format(**conv))
        # XCD  ==> $
        # AUD  ==> $
        # BWP  ==> Pu
        # CAD  ==> $
        # DKK  ==> kr
        # GBP  ==> £
        # HKD  ==> HK$
        # EUR  ==> €
        # INR  ==> ₨
        # NGN  ==> ₦
        # NZD  ==> $
        # PHP  ==> Php
        # SGD  ==> $
        # USD  ==> $
        # ZAR  ==> R
        # ZWD  ==> Z$
        # JPY  ==> ¥
    

    This depends on what locales are installed on your machine. On *nix machines, you can find out what locales are available with the command locale -a.

提交回复
热议问题