尝试从十六进制的某些字节解码浮点数时遇到问题。
我从zmq消息中读取字节并添加到数组中,然后使用struck unpack对它们进行解码。但我得到了这个错误:
lengthOfSensor = frameReceived[count + 1]
print(lengthOfSensor) #number of bytes I have to read for that value
vv = [None] * lengthOfSensor #init array
for cc in range(0, lengthOfSensor):
print(count+1+cc)
vv[cc] = frameReceived[count+1+cc]
print("Measurement")
print(struct.unpack('f',vv))
count是一个计数器,工作正常,因为我得到了我想要的字节。我已经导入了struct module。如果您认为还需要其他任何内容来查找我的错误,请询问
Fulltraceback:
Traceback (most recent call last):
File "scriptA.py", line 77, in <module>
parseFrame(message[1])
File "scriptA.py", line 56, in parseFrame
print(struct.unpack('f',vv))
TypeError: 'list' does not support the buffer interface