python2 生成HTML测试报告报错 ascii code can't decode byte 0xe5 in position 0:ordinal not in range(128)

 原因:python2 默认的编码格式是ascii 很多编码格式转换不了

解决方法:

我是直接替换到python3环境解决的

你需要的是让编码用实际编码而不是 ascii

1.
对需要 str->unicode 的代码,可以在前边写上
import sys
reload(sys)
sys.setdefaultencoding('utf8')
把 str 编码由 ascii 改为 utf8 (或 gb18030)

2.
python3 区分了 unicode str 和 byte arrary,并且默认编码不再是 ascii

原文地址:https://www.cnblogs.com/lin-yue/p/10938746.html