Re: [newbie] String to binary conversion

2012-08-07 Thread 88888 Dihedral
Steven D'Aprano於 2012年8月7日星期二UTC+8上午10時01分05秒寫道: > On Mon, 06 Aug 2012 22:46:38 +0200, Mok-Kong Shen wrote: > > > > > If I have a string "abcd" then, with 8-bit encoding of each character, > > > there is a corresponding 32-bit binary integer. How could I best obtain > > > that integer and from

Re: [newbie] String to binary conversion

2012-08-06 Thread Steven D'Aprano
On Mon, 06 Aug 2012 22:46:38 +0200, Mok-Kong Shen wrote: > If I have a string "abcd" then, with 8-bit encoding of each character, > there is a corresponding 32-bit binary integer. How could I best obtain > that integer and from that integer backwards again obtain the original > string? Thanks in a

Re: [newbie] String to binary conversion

2012-08-06 Thread Emile van Sebille
On 8/6/2012 1:46 PM Mok-Kong Shen said... If I have a string "abcd" then, with 8-bit encoding of each character, there is a corresponding 32-bit binary integer. How could I best obtain that integer and from that integer backwards again obtain the original string? Thanks in advance. It's easy t

Re: [newbie] String to binary conversion

2012-08-06 Thread MRAB
On 06/08/2012 21:46, Mok-Kong Shen wrote: If I have a string "abcd" then, with 8-bit encoding of each character, there is a corresponding 32-bit binary integer. How could I best obtain that integer and from that integer backwards again obtain the original string? Thanks in advance. Try this (P

Re: [newbie] String to binary conversion

2012-08-06 Thread Mok-Kong Shen
Am 06.08.2012 22:59, schrieb Tobiah: The binascii module looks like it might have something for you. I've never used it. Thanks for the hint, but if I don't err, the module binascii doesn't seem to work. I typed: import binascii and a line that's given as example in the document: crc = bina

Re: [newbie] String to binary conversion

2012-08-06 Thread Tobiah
On 08/06/2012 01:59 PM, Tobiah wrote: The binascii module looks like it might have something for you. I've never used it. Having actually read some of that doc, I see it's not what you want at all. Sorry. -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] String to binary conversion

2012-08-06 Thread Tobiah
The binascii module looks like it might have something for you. I've never used it. Tobiah http://docs.python.org/library/binascii.html On 08/06/2012 01:46 PM, Mok-Kong Shen wrote: If I have a string "abcd" then, with 8-bit encoding of each character, there is a corresponding 32-bit binary i