UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 3136: illegal multibyte sequence

import codecs
def read_glove_vecs(glove_file):
    with open(glove_file, 'r', encoding='utf-8') as f:   # 修改这个
        words = set()
        word_to_vec_map = {}
        
        for line in f:
            line = line.strip().split()
            curr_word = line[0]
            words.add(curr_word)
            word_to_vec_map[curr_word] = np.array(line[1:], dtype=np.float64)
            
    return words, word_to_vec_map

重启jupyter

posted @ 2020-06-29 22:46  douzujun  阅读(866)  评论(0编辑  收藏  举报