-
返回v1, v2, ...打包成format格式的bytes对象(即buffer)
-
format
-
v1, v2, ...
-
例:
- format:
16sH
,16s1H
,16s H
,16s 1H
- v1: 长16的char数组
- v2: 一个无符号短整型
>>> struct.pack('16sH', b'bbb', 1) b'bbbx00x00x00x00x00x00x00x00x00x00x00x00x00x01x00' >>> struct.pack('16s1H', b'bbb', 1) b'bbbx00x00x00x00x00x00x00x00x00x00x00x00x00x01x00' >>> struct.pack('16s 1H', b'bbb', 1) b'bbbx00x00x00x00x00x00x00x00x00x00x00x00x00x01x00'
- format:
-
-
unpack就是解包