我试图用类val
中的元素value
的可变大小构造结构:
from construct import *
TEST = Struct("test",
UInt8("class"),
Embed(switch(lambda ctx: ctx.class) {
1: UInt8("value"),
2: UInt16("value"),
3: UInt32("value")}
))
)
以上代码不正确。你知道吗
我需要实现这样的功能:如果类是1,那么将从数据包接收一个字节。你知道吗
Tags:
您可以使用多个format string来更改
struct
行为,并使用struct.calcsize
来继续从最后找到的字节序列的末尾分析bytearray:相关问题 更多 >
编程相关推荐