我正在使用 pySerial 从 Arduino(微控制器)获取数据。
数据存储在 pickle 文件中。它适用于 Blender 2.49 (python 2.7)。
现在,转移到 Blender 2.56 (python 3.2),我收到以下错误:
f=open('abc.dat','r')
with serial.Serial('COM31',9600) as port :
for i in range(0, 10):
x = port.read(size=1)
print(int(x))
y=pickle.load(f)
f.close()
f=open('abc.dat','w')
y.append(i)
pickle.dump(y,f)
f.close()
port.close()
error:
Python script error from controller "Python Script#CONTR#1":
Traceback (most recent call last):
File "256script1.py", line 18, in <module>
f.close()
File "C:\PROGRA~1\BLENDE~1\Blender\2.54\python\lib\pickle.py", line 1365, in l
oad
encoding=encoding, errors=errors).load()
ValueError: read() from the underlying stream did notreturn bytes
Blender Game Engine Finished
使用上是否有任何操作上的变化pickle
?