str(int_var) formatted

John Yeung gallium.arsenide at
Sat Oct 30 04:18:41 CEST 2010

On Oct 29, 11:59 am, Tracubik <affdfsdfds... at> wrote:
> i've to convert integer x to string, but if x < 10,
> the string have to be '0x' instead of simple 'x'
> for example:
> x = 9
> str(x) --> '09'

Everyone else seems to prefer the format-based solutions, which is
fine.  I will give zfill a little exposure, as it seems unloved/



More information about the Python-list mailing list