其他分享
首页 > 其他分享> > UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position

UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position

作者:互联网

记录一下问题解决办法

 

通过Python把数据流写入文件时,提示报错。

UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 18521: illegal multibyte sequence

 

具体如下

f = open("out.html","w")

 

解决办法:

改变目标文件编码

f = open("out.html","w",encoding='utf-8')

 

参考:

https://blog.csdn.net/qq_38008452/article/details/80423436

 

 

标签:sequence,xa0,illegal,multibyte,character,codec,open,out
来源: https://www.cnblogs.com/wmzhong/p/14591478.html