struct.error:解包需要长度为2的字符串参数(struct.error: unpack r

2019-10-18 08:26发布

我有这样的下面的代码它的工作原理64位的另一台计算机,但它不与我的工作,给休耕error.I使用Python 3.3和该电源线库。 我能不能解决问题,请帮助。

import matplotlib.pyplot as plt
import binascii
import numpy
import struct

array = []
out = open('output.txt','wb')

a=int(input("Enter the first value:"))
b=int(input("Enter the second value:"))

with open("thefile.bin", "rb") as f:

    i=0 
    for i in range(0, a):
        byte = f.read(1)

    i=0
    for i in range(a,b):
        byte = f.read(1)
        value = struct.unpack('B', byte)[0]
        array.append(value)


plt.plot(array)
plt.ylabel('Value')
plt.show()
文章来源: struct.error: unpack requires a string argument of length 2