TypeError: a bytes-like object is required, not 'str' while loading with pickle

前端 未结 1 663
独厮守ぢ
独厮守ぢ 2021-01-28 06:24

I\'m using Python 3.6 and Spyder (Anaconda). I have tried many things but nothing worked out. I don\'t know why this error is coming always to me while loading with pickle.

相关标签:
1条回答
  • 2021-01-28 06:37

    You need to open your file as a binary file:

    pickle.loads(open("accounts.txt", 'rb').read())
    

    Otherwise, it's using an str to read the data.

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