struct.pack returns nothing

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Mar 19 01:46:57 EDT 2007


En Mon, 19 Mar 2007 02:39:01 -0300, <andmarti at gmail.com> escribió:

> On Sun, Mar 18, 2007 at 10:22:32PM -0700, Alex Martelli wrote:
>> <andmarti at gmail.com> wrote:
>>
>> > import struct
>> > print struck.pack ('i', 1)
>> >
>> > it returns a '\n'.
>> > What's wrong with it???
>> > :(
>>
>> You're trying to print a binary string that's hardly printable as-is.
>> Try printing its repr(...) and you'll see all the binary zeros and one
>> you crave!-)
>
> Im getting nothing as well.
> The unpack seems to work fine though.

Works fine for me:

py> import struct
py> print repr(struct.pack('i',1))
'\x01\x00\x00\x00'

-- 
Gabriel Genellina




More information about the Python-list mailing list