一、 函数定义
struct.pack_into(fmt, buffer, offset, v1, v2, ...)
Pack the values v1, v2, ... according to the format string fmt and write the packed bytes into the writable buffer buffer starting at position offset. Note that offset is a required argument.
按照指定的格式fmt,将v1,v2...打包到buffer中,其中偏移位置为offset
struct.unpack_from(fmt, buffer, offset=0)
Unpack from buffer starting at position offset, according to the format string fmt. The result is a tuple even if it contains exactly one item. The buffer’s size in bytes, minus offset, must be at least the size required by the format, as reflected by calcsize().
按照指定的格式fmt,从偏移位置offset开始解包,返回数据格式是一个元组(v1,v2...)
二、简单的脚本示例
from ctypes import create_string_buffer
import struct
import binascii
#创建了一个7个字节长度的buffe