struct.pack Format String Question
Larry Bates
lbates at swamisoft.com
Tue Mar 30 18:32:46 EST 2004
"B" is unsigned character (from Python Library Reference).
I'm hoping you copied the line down wrong, because it won't
work (there is probably another B).
See output below:
import struct
word0=1
word1=2
word2=3
word3=4
word4=5
msg = struct.pack('BBBB',word0, word1, word2, word3, word4)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
error: too many arguments for pack format
Larry Bates
Syscon, Inc.
-------------------------------------------------------
"Joshua Forgione" <jforgion at vt.edu> wrote in message
news:4069E5C6.BC5274E6 at vt.edu...
> Hello. I am reverse engineering some Python Code. I am using the book
> "The Quick Python Book" as an aide.
>
> The following line exists in the code:
>
> msg = struct.pack('BBBB',word0, word1, word2, word3, word4)
>
> In this struct.pack command, the format string is 'BBBB.' In the book,
> it gives the following examples for characters that are meaningful to
> struct:
>
> 'h' - short integer
> 'd' - double-precision floating point
> 's' - string
>
> In this case, 'B' is used. What does 'B' represent? What other
> characters can be used? Does a list of this exist somewhere?
>
> Thank you for your help.
>
> Josh
>
More information about the Python-list
mailing list