import locale
locale.setlocale(locale.LC_ALL, '')
for cents in [1234, 5, 999]:
    locale.currency(float(cents) / 100.0)
How to use Python string formatting to convert an integer representing cents to a float representing dollars?