Iteratively unpack from the buffer buffer according to the format string fmt. This function returns an iterator which will read equally-sized chunks from the buffer until all its contents have been consumed. The buffer’s size in bytes must be a multiple of the size required by the format, as reflected by calcsize().
Each iteration yields a tuple as specified by the format string.
struct.unpack
中没有这样的功能,但是可以定义这样一个函数:在Python3.4和更高版本中,可以使用新函数^{} 。在
假设我们要用重复格式字符串}。在
'<2sc'
(2个字符后跟一个字符,重复直到完成)来解压数组{使用
iter_unpack
,可以执行以下操作:如果要取消嵌套此结果,可以使用^{} 执行此操作。在
^{pr2}$当然,您可以使用嵌套的理解来做同样的事情。在
相关问题 更多 >
编程相关推荐