admin管理员组

文章数量:1610901

UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x9d in position 3201: character maps to
读入TXT时,发生以下错误:

def write_to_file(words, file="english2.csv"):
    f = open(file, 'w',encoding='UTF-8')
    for item in words:
        for field in item:
            f.write(str(field)+',')
        f.write('\n')

#%%

if __name__=='__main__':
    print ("counting...")
    words = get_words("G://english2.txt")
    write_to_file((words.most_common()))

本文标签: DecodebyteCodecUnicodeDecodeErrorcharmap