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

记录一下问题解决办法

 

通过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

 

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

 

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

上一篇:js代理(Proxy)和反射(Reflect)的应用


下一篇:如何修改hexo中主题的css