#寫入
d = dict(name = 'xioazhi', num = 1002)
with open('./Test.txt', 'wb') as f:
pickle.dump(d, f)
#讀取
with open('./Test.txt', 'rb') as f:
print(f.read())
try:
print(pickle.load(f))
except EOFError:
print('None')
打印結果如下Screen Shot 2018-04-07 at 16.02.32.png
出現(xiàn)這個錯誤的原因漏设,網(wǎng)上說是因為文件為空墨闲,可是文件不為空。
也有說是不同版本可能不兼容鸳碧。
記錄一下。有沒有遇見過這個問題的