在保存网页文字到txt文件下时,出现如下错误
UnicodeEncodeError: 'gbk' codec can't encode character u'\xa9' in position 24051: illegal multibyte sequence
解决方法:
with open(“d:/1.txt”,‘a’,encoding=‘gb18030’) as f:
GB18030是GBK的父集,所以能兼容GBK不能编码的字符
2023-10-15 20:18:46
在保存网页文字到txt文件下时,出现如下错误
UnicodeEncodeError: 'gbk' codec can't encode character u'\xa9' in position 24051: illegal multibyte sequence
解决方法:
with open(“d:/1.txt”,‘a’,encoding=‘gb18030’) as f:
GB18030是GBK的父集,所以能兼容GBK不能编码的字符