struct.error: unpack requires a string argument of length 2

别说谁变了你拦得住时间么 提交于 2019-12-24 18:21:43

问题


I have this following code it works 64bit another computer but it does not work with mine and gives the fallowing error.I use Python 3.3 and the requiered libraries. I could not solve the problem please help.

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()

来源:https://stackoverflow.com/questions/17579444/struct-error-unpack-requires-a-string-argument-of-length-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!