python如何用位域宽度打包struct?

2024-04-26 03:29:35 发布

您现在位置:Python中文网/ 问答频道 /正文

//c struct code with filed width:

    struct{
      unsigned int x:1;
      unsigned int y:25;
      unsigned int z:6;
    };

现在我想用python重写它,打包并发送到网络

python中的package结构可以打包/解包数据类型。在

例如:

^{pr2}$

但是我不知道如何处理像c结构这样的文件宽度的结构。有人知道吗?在


Tags: 文件网络package宽度withcodewidth结构