Concatening string and integer
Remco Gerlich
scarblac-spamtrap at pino.selwerd.nl
Thu Apr 27 09:53:03 EDT 2000
JJ wrote in comp.lang.python:
> Hi!
>
> I want to concatenate a string containing both strings and integers like:
>
> strTemp = 'I make test number: ' + iMyNumber + ' once again'
>
> It doesn't work, how should I do this?
1) You make a string of the integer:
strTemp = 'I make test number: ' + str(iMyNumber) + ' once again'
2) You use string formatting:
strTemp = 'I make test number: %d once again' % iMyNumber
--
Remco Gerlich, scarblac at pino.selwerd.nl
Hi! I'm a .sig virus! Join the fun and copy me into yours!
More information about the Python-list
mailing list