わりと使うかも
2014-04-05リファクタした
#!/usr/bin/env python # *-# -*- coding: utf-8 -*- import locale locale.setlocale(locale.LC_NUMERIC, 'ja_JP') def number_to_currency(num): """ >>> print(number_to_currency(1234567890)) 1,234,567,890 """ return locale.format('%d', num, True) def _test(): import doctest doctest.testmod() if __name__ == '__main__': _test()
なんとなくdoctestもやってみた