首页 > 代码库 > python——unpack问题 ocr_recognize timeout , exception:unpack requires a string argument of length 46

python——unpack问题 ocr_recognize timeout , exception:unpack requires a string argument of length 46

rObjBuff = "".join(unpack(‘=%ds‘ % ObjLen, recv_buf[6+i*ObjLen:6+(i+1)*ObjLen]))
score, bbox1, bbox2, bbox3, bbox4, p00, p01, p10, p11, p20, p21, p30, p31, p40, p41 = unpack(‘=5f10H‘, rObjBuff)

 

错误示例:

rObjBuff = unpack(‘=%ds‘ % ObjLen, recv_buf[6+i*ObjLen:6+(i+1)*ObjLen])

score, bbox1, bbox2, bbox3, bbox4, p00, p01, p10, p11, p20, p21, p30, p31, p40, p41 = unpack(‘=5f10H‘, rObjBuff)

此时第二次unpack报错:ocr_recognize timeout , exception:unpack requires a string argument of length 40

,因为rObjBuff此时是tuple元组,而不是list,所以要"".join进行转换。

python——unpack问题 ocr_recognize timeout , exception:unpack requires a string argument of length 46