python如何使用位字段宽度打包结构?
现在我想用python重写它,打包并发送到网络 python中的包结构可以打包/解包数据类型 例如:python如何使用位字段宽度打包结构?,python,c,struct,Python,C,Struct,现在我想用python重写它,打包并发送到网络 python中的包结构可以打包/解包数据类型 例如: //c struct code with filed width: struct{ unsigned int x:1; unsigned int y:25; unsigned int z:6; }; 但是我不知道如何像c struct示例那样处理具有字段宽度的struct。有人知道吗?有什么帮助吗??可能是一个复制品。我看到了。现在找到一个
//c struct code with filed width:
struct{
unsigned int x:1;
unsigned int y:25;
unsigned int z:6;
};
但是我不知道如何像c struct示例那样处理具有字段宽度的struct。有人知道吗?有什么帮助吗??可能是一个复制品。我看到了。现在找到一个更好的链接,只需将整个内容作为一个未签名的符号来阅读,然后进行掩码和移位。就像链接文章一样。然而,位字段的可移植性是值得怀疑的。
struct.pack('!I10s',1,'hello')