求助【UnicodeDecodeError: ‘charmap‘ codec can‘t decode byte 0x9d in position 3201character maps to <un】

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()))

在这里插入图片描述


版权声明:本文为weixin_45479073原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。