码迷,mamicode.com
首页 > Web开发 > 详细

HTMLTestRunner 异常输出中文乱码

时间:2016-08-19 14:45:19      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

1.在代码中加入下面的代码并保存:
  1. # -.- coding:utf-8 -.-
  2. import sys
  3. reload(sys)
  4. sys.setdefaultencoding(‘utf-8‘)

2.找到HTMLTestRunner.py源码 

定位到如下位置,o.decode(‘latin-1’)编码“latin-1”修改为“utf-8”


if isinstance(o,str):
    # TODO: some problem with ‘string_escape‘: it escape \n and mess up formating
    # uo = unicode(o.encode(‘string_escape‘))
    uo = o.decode(‘utf-8‘)
else:
    uo = o
if isinstance(e,str):
    # TODO: some problem with ‘string_escape‘: it escape \n and mess up formating
    # ue = unicode(e.encode(‘string_escape‘))
    ue = e.decode(‘utf-8‘)
else:
    ue = e

  



 

HTMLTestRunner 异常输出中文乱码

标签:

原文地址:http://www.cnblogs.com/saryli/p/5787421.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!