我相信 Rebuild 就是你要找的,在这种情况下。
Rebuild
Construct's docs :
>>> st = Struct( ... "count" / Rebuild(Byte, len_(this.items)), ... "items" / Byte[this.count], ... ) >>> st.build(dict(items=[1,2,3])) b'\x03\x01\x02\x03'