struct — Interpret bytes as packed binary data,将字节与二进制文件相互转化的工具Python struct 模块。更多见:iii.run
关于格式字符串
在Python手册中,给出了C语言中常用类型与Python类型对应的格式符:
格式符
C语言类型
Python类型
x
pad byte
no value
c
char
string of length 1
b
signed char
integer
B
unsigned char
integer
?
_Bool
bool
h
short
integer
H
unsigned short
integer
i
int
integer
I
unsigned int
integer or long
l
long
integer
L
unsigned long
long
q
long long
long
Q
unsigned long
long long
f
float
float
d
double
float
s
char[]