【发布时间】:2022-01-17 22:41:11
【问题描述】:
我有一个嵌套的 C 结构(大小非常大)和字节
// In C:
struct example1 {
int val1;
int val2;
int val3;
int val4;
char c1;
char c2;
enum example2 e1;
union example3 u1;
struct example4 s1;
...
....
....
};
# In python
example1_bytes = b'\x08\x09\x0a\x0b...........'
如何将字节映射到 C 结构并访问成员?
【问题讨论】:
-
我想用python来处理
-
你试过在
python写代码吗? -
可以,但是结构很复杂,不知道怎么处理
-
您能否提供一个minimal reproducible example 来满足您的需求?通常的答案是
struct模块,但看起来你需要的不止这些——例如嵌套unions 和structs。
标签: python python-3.x struct