UnicodeEncodeError: ‘gbk‘ codec can‘t encode character ‘\xa0‘ in position 302: illegal multibyte seq

写csv文件时报错,如下:UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 302: illegal multibyte sequence

改为:加编码限制:encoding = "utf-8"

with open("C:\\Users\\xxx\\Desktop\\newdata.csv",'w',encoding = "utf-8",newline='') as file:
    writer = csv.writer(file)
    writer.writerows(li)

你可能感兴趣的:(自然语言处理,优雅的python,p2p,c#,网络协议)