pickle.load() raising EOFError in Windows

后端 未结 1 1677
天涯浪人
天涯浪人 2020-12-01 23:32

This is how the code is

with open(pickle_f, \'r\') as fhand:
    obj = pickle.load(fhand)

This works fine on Linux systems but not on Wind

1条回答
  •  旧巷少年郎
    2020-12-02 00:37

    Always use b mode when reading and writing pickles (open(f, 'wb') for writing, open(f, 'rb') for reading). To "fix" the file you already have, convert its newlines using dos2unix.

    0 讨论(0)
提交回复
热议问题