Python pickle: fix \r characters before loading

前端 未结 4 1749
忘掉有多难
忘掉有多难 2021-01-02 13:38

I got a pickled object (a list with a few numpy arrays in it) that was created on Windows and apparently saved to a file loaded as text, not in binary mode (ie. with

4条回答
  •  青春惊慌失措
    2021-01-02 14:25

    Have you tried unpickling in text mode? That is,

    x = pickle.load(open(filename, 'r'))
    

    (On Windows, of course.)

提交回复
热议问题