| ||||
Printing out currencies in Python Posted by enquirer (enquirer), 23 January 2004 How do I print out the number contained in a float object in Python to a certain number of decimal places? How do I format a time so that if I have an hour of 7 and a minute of 9 it comes out as 07:09?Posted by admin (Graham Ellis), 23 January 2004 In Python, the % operator is overloaded - it gives "remainder when divided by" if the parameter to the left of the % character is a numeric object type, and it gives "formatted to" if the parameter to the left of the % character is a string.In other words, the % operator in python is like the sprintf function in Perl, PHP and C. Sample program: Code:
This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| ||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |