相关疑难解决方法(0)

Python有比特字段类型吗?

我需要一个布尔数组的紧凑表示,Python有内置的位域类型还是我需要找到一个替代解决方案?

python bitarray bit-fields

44
推荐指数
6
解决办法
4万
查看次数

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 结构示例。有人知道吗?

c python struct

3
推荐指数
1
解决办法
4674
查看次数

标签 统计

python ×2

bit-fields ×1

bitarray ×1

c ×1

struct ×1