[Tutor] Question: Converting ints to strings
Jason Stokes
jstok@bluedog.apana.org.au
Mon, 24 Apr 2000 17:23:19 +1000
-----Original Message-----
From: Fiel Cabral <fcabral@i-next.net>
To: tutor@python.org <tutor@python.org>
Date: Sunday, April 23, 2000 11:48 AM
Subject: [Tutor] Question: Converting ints to strings
>Please tell me how to convert an int to a string.
>I'm trying to do the following:
>
> block_number = 1
> file_name = 'temp.file'
> output = open(file_name + '.$' + block_number + '$', 'wb')
>
>This didn't work. I was hoping that it would create
>a file called 'temp.file.$1$'.
For any object x, str(x) will return a string which is a printable
representation of that object.
so you can use:
output = open(file_name + '.$' + str(block_number) + '$', 'wb')
Cheers,
Jason Stokes: jstok@bluedog.apana.org.au