我需要一个布尔数组的紧凑表示,Python有内置的位域类型还是我需要找到一个替代解决方案?
//c struct code with filed width:
struct{
unsigned int x:1;
unsigned int y:25;
unsigned int z:6;
};
Run Code Online (Sandbox Code Playgroud)
现在我想用python重写它,打包并发送到网络,
python中的package结构体,可以打包/解包数据类型。
例如:
struct.pack('!I10s',1,'hello')
Run Code Online (Sandbox Code Playgroud)
但我不知道如何处理具有字段宽度的结构,如 c 结构示例。有人知道吗?