tertius wrote:
Hi,
Is there a builtin function that will enable me to display the hex
notation of a given binary string? (example below)
Thanks all.
--
http://mail.python.org/mailman/listinfo/python-list
Grant Edwards wrote:
On 2005-01-18, Grant Edwards <[EMAIL PROTECTED]> wrote:
On 2005-01-18, tertius <[EMAIL PROTECTED]> wrote:
Is there a builtin function that will enable me to display the hex
notation of a given binary string? (example below)
' '.join('%02x' % ord(b) for b in s)
Oops. Should
On 2005-01-18, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2005-01-18, tertius <[EMAIL PROTECTED]> wrote:
>
>> Is there a builtin function that will enable me to display the hex
>> notation of a given binary string? (example below)
>
> ' '.join('%02x' % ord(b) for b in s)
Oops. Should be:
' '
On 2005-01-18, tertius <[EMAIL PROTECTED]> wrote:
> Is there a builtin function that will enable me to display the hex
> notation of a given binary string? (example below)
' '.join('%02x' % ord(b) for b in s)
--
Grant Edwards grante Yow! This is a NO-FRILLS
This will do it:
>>> int('1000', 2)
128
>>> hex(int('1000', 2))
'0x80'
>>>
--
http://mail.python.org/mailman/listinfo/python-list
Would that do it?
for i in my_byte_string:
= atoi(binascii.hexlify(i),16)
Regards,
Philippe
On Tue, 18 Jan 2005 20:43:44 +0200, tertius wrote:
> Hi,
>
> Is there a builtin function that will enable me to display the hex
> notation of a given binary string? (example below)
>
> man
tertius wrote:
Hi,
Is there a builtin function that will enable me to display the hex
notation of a given binary string? (example below)
Does this help:
>>> "hello".encode("hex")
'68656c6c6f'
>>> "deadbeef".decode("hex")
'\xde\xad\xbe\xef'
?
--Irmen
--
http://mail.python.org/mailman/listinfo/pytho