[Tutor] Covert numbers to hex fails
Tom Tucker
tktucker at gmail.com
Wed May 25 05:14:18 CEST 2005
Thanks! <sigh> I see the mistake.
On 5/24/05, Tony Meyer <tameyer at ihug.co.nz> wrote:
> > FAILS
> > ----------
> > >>> value = 1234567890
> > >>> hexoutput = hex('%d' % (value))
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in ?
> > TypeError: hex() argument can't be converted to hex
>
> Just don't convert the number to a string, e.g:
>
> >>> value = 1234567890
> >>> hexoutput = hex(value)
> >>> hexoutput
> '0x499602d2'
>
> =Tony.Meyer
>
>
More information about the Tutor
mailing list