2021-02-22-'utf-8' codec can't encode characters in position 60263-60268: surrogates not

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2021-02-22-'utf-8' codec can't encode characters in position 60263-60268: surrogates not相关的知识,希望对你有一定的参考价值。

参考技术A 在用python3.7.4+requests+allure+pytest框架运行接口自动化脚本时,报了如下错误:

经过百度后,找到解决方法:

将/home/zhangxiaolin/.pyenv/versions/3.7.4/lib/python3.7/site-packages/allure_commons/logger.py文件中的attached_file.write(body.encode('utf-8'))方法改为 attached_file.write(body.encode('utf-8',errors='surrogatepass'))

以上是关于2021-02-22-'utf-8' codec can't encode characters in position 60263-60268: surrogates not的主要内容,如果未能解决你的问题,请参考以下文章

bytes(' xFF','utf-8')返回

'utf8'编解码器在python中解码('utf-8')时无法解码字节0xc3

用Python 抓取的UTF8网页无法decode('utf-8')

UnicodeDecodeError: 'utf-8' codec can't decode byte

header.setContentDispositionFormData("attachment;filename*=UTF-8''", fileName);无法设

导入Excel文件到pandas中报错,更改encoding='utf-8',gb18030,gbk 都没用?