[Tutor] format integer to currency

Steven D'Aprano steve at pearwood.info
Wed Nov 16 22:46:00 CET 2011


ADRIAN KELLY wrote:
> 
> print ("i own {0:.2f} {1}".format(1.1,"million"))
> 
> can anyone help me with code to change the format of this to currency €1.10 million
> thanks for your help

# Python 2.6 or 2.7
print (u"I own €{0:.2f} {1}".format(1.1, "million"))


# Python 3
print ("I own €{0:.2f} {1}".format(1.1, "million"))



-- 
Steven


More information about the Tutor mailing list