Pickled file won't load on Mac/Linux

后端 未结 5 1154
余生分开走
余生分开走 2020-12-10 18:41

I have an application that imports data from a pickled file. It works just fine in Windows but Mac and Linux behaviour is odd.

In OS X, the pickled file (file extens

5条回答
  •  醉酒成梦
    2020-12-10 19:12

    Probably you didn't open the file in binary mode when writing and/or reading the pickled data. In this case newline format conversion will occur, which can break the binary data.

    To open a file in binary mode you have to provide "b" as part of the mode string:

    char_file = open('pickle.char', 'rb')
    

提交回复
热议问题