简体   繁体   中英

UnicodeDecodeError: 'ascii' codec can't decode byte 0xdb in position 0: ordinal not in range(128)

When I am loading a file using pickle.load at that time I am facing this error.

with open("tfidf_vectorizer", mode='r+b') as handle:                            
    tfidf_vectorizer = pickle.load(handle)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xdb in position 0: ordinal not in range(128)

Try setting an encoding when reading the file.

Ex:

with open("tfidf_vectorizer", mode='r+b', encoding='utf-8') as handle:                            
    tfidf_vectorizer = pickle.load(handle)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM