0

When reading a file with this code faced error:

with open("hist", "rb") as f:
    hist = pickle.load(f)


hist = pickle.load(f)

Error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 3582: ordinal not in range(128)
ShivaGaire
  • 1,348
  • 16
  • 26
SarwarKhan
  • 123
  • 1
  • 2
  • 10
  • Is the problem with the second statement? – Nathan Mar 05 '18 at 04:45
  • 1
    Perhaps [this](https://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte) solves your problem? – Nathan Mar 05 '18 at 04:47

1 Answers1

2

Try setting the encoding while load.

Ex:

hist = pickle.load(f, encoding='utf-8') #or'latin1' or 'bytes'
Rakesh
  • 78,594
  • 17
  • 67
  • 103