Converting itegers to strings

Phil Mayes nospam at bitbucket.com
Sat Jul 24 00:01:31 EDT 1999


Chris Frost wrote in message <19990723171921.A5205 at pooh.frostnet.net>...

>How can you convert numbers (an interger in this case) to strings? (i.e. I
>have some_number = 3, and would like to use it as a string)


Yeah, there's no itoa() -- use the printf equivalent:
>>> print "%d" % some_number
3

Multiple numbers are supplied as a tuple:
>>> h = 7
>>> m = 45
>>> print "%02d:%02d" % (h,m)
07:45
--
Phil Mayes    pmayes AT olivebr DOT com







More information about the Python-list mailing list