hex numbers??
Ulli Stein
mennosimons at gmx.net
Tue Sep 24 15:01:44 EDT 2002
jubafre at brturbo.com wrote:
>>>> y=hex(x)
>>>> y
> '0xa'
>>>> type(y)
> <type 'str'>
>
> the hex() function put the hexadecimal number in a string type like this
> '0xa', but the real hexadecimal number of 10 is 'a', why python puts a
> '0x', and how i can get just the real hexadedcimal number, for example i
> want to write in a file 10 in hexadecimal, but if i use hex(10) the result
> is '0xa' as a string, is not the same as 'a'.
>
> '0xa' != 'a'
>
> x = [12,13,14]
> y = ['0xc', '0xd', '0xe']
>
> hex() create a list of string, how i can write in a file just the real
> value of hexadecimal number?
>
>
> Juliano Freitas
> www.gebrasil.hpg.com.br
With your nice Python strings:
>>> "%x, %x, %x, %x"%(1,10,14,24234234)
'1, a, e, 171c8fa'
Have fun.
More information about the Python-list
mailing list