python出现UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 21: illegal multibyte sequence

不管是爬冲导出数据还是读取excel文件的时候都可以用

 

 参考:http://blog.csdn.net/jim7424994/article/details/22675759

    https://blog.csdn.net/u012680593/article/details/53814340

 

在代码前加上这几句

import sys,io

sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')

 就ok了

posted @ 2021-03-07 23:50  This_is_Y  阅读(556)  评论(0编辑  收藏  举报