You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@ : native order, size & alignment (default)
= : native order, standard size & alignment
< : little-edian, standard size & alignment
> : big-edian, standard size & alignment
! : same as >
Remaining chars.
[optional preceding decimal indicates repetition]
x : pad byte -> no value
c : char -> string (len == 1)
b : signed char -> integer
B : unsigned char -> integer
? : _Bool -> bool (if C99 available, otherwise char)
h : short -> integer
H : unsigned short -> integer
i : int -> integer
I : unsigned int -> integer or long
l : long -> integer
L : unsigned long -> long
f : float -> float
d : double -> float
[preceding decimal indicates lenght]
s : char[] (C string) -> string
p : pascal array -> string (short variable-length string stored in a fixed number of bytes, first byte is the lenght of the string)
[Only available in native format.]
P : int/long type that holds a pointer (void *) -> long
[Not in native mode unless 'long long' in platform C.]
g : long long -> long
Q : unsigned long long -> long
Exceptions
struct.error
Functions
calcsize(format_string) - returns size of C struct
pack(format_string, v1, v2, ...) - returns string represented struct
pack_into(format_string, buffer, offset, v1, v2, ...) - same as pack but writes to buffer and accepts an offset
unpack(format_string, struct_string) - returns tuple representation of the struct, len(struct_string) == calcsize(format_string)
unpack_from(format_string, buffer[, offset=0]) - unpack buffer from offset
Thankyou - very useful!