从二进制文件中取消数据

时间:2018-06-07 14:15:28

标签: python-3.x file binary pickle

当我试图解析/读取BIN文件时,我收到此错误:

    temp_data = pickle.load(f)
_pickle.UnpicklingError: pickle data was truncated

我以前打开的代码:

import pickle
data = []
with open('wf_cm_cap_000110.bin','rb') as f:
    temp_data = pickle.load(f)
    with open('wf_cm_cap_000110.txt','w') as new_file:
        # data = new_file.writelines()
        new_file.write(str(temp_data))

打开GOOD的文件:

https://ufile.io/wn6b5

我遇到问题的文件:

https://ufile.io/48cqh

任何帮助人员?

感谢

这是我创建文件的代码,打开的很好:

使用此代码:

from itertools import chain


import pickle

data = '1213,234234,234234,2234,127567,3453'



new_list=[]

new = list(chain(*data))
new_str = ' '.join(str(e) for e in new)






with open('temp.bin', 'wb') as f:
    pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)

0 个答案:

没有答案