Convert an amount to Indian Notation in Python

前端 未结 5 711
离开以前
离开以前 2021-01-02 03:40

Problem: I need to convert an amount to Indian currency format

My code: I have the following Python implementation:

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 04:20

    Too much work.

    >>> import locale
    >>> locale.setlocale(locale.LC_MONETARY, 'en_IN')
    'en_IN'
    >>> print(locale.currency(100.52, grouping=True))
    ₹ 100.52
    >>> print(locale.currency(1000.108, grouping=True))
    ₹ 1,000.11
    >>> print(locale.currency(1200000, grouping=True))
    ₹ 12,00,000.00
    

提交回复
热议问题