converting an integer to a string
Asun Friere
afriere at yahoo.co.uk
Wed Aug 6 02:32:26 EDT 2003
"Sean Ross" <sross at connectmail.carleton.ca> wrote in message news:<2AZXa.2573$_a4.492504 at news20.bellglobal.com>...
> "Ken Fettig" <kenfettig at btinet.net> wrote in message
> news:bgpl6401e66 at enews4.newsguy.com...
> > I have a quick simple question. How do you convert an integer to a string
> in
> > Python?
>
>
> >>> 1
> 1
> >>> str(1)
> '1'
> >>>
>
> HTH,
> Sean
Depending on where and why you want to convert it
>>> "%d" % 1
'1'
might be useful too.
eg..
>>> dat = (12, 'Spam Street')
>>> "%d %s" % dat
'12 Spam Street'
More information about the Python-list
mailing list