NameError: name 'unicode' is not defined

上一篇 / 下一篇  2017-11-22 15:33:58 / 个人分类:Selenium

在使用BSTestRunner生成测试报告的时候,如果有NameError: name 'unicode' is not defined出现在

def to_unicode(s):
    try:
       return unicode(s)
    except UnicodeDecodeError:
        # s is non ascii byte string
        return s.decode('unicode_escape')

可以尝试将代码改为
def to_unicode(s):
    try:
        #return unicode(s)
       return s.encode()
    except UnicodeDecodeError:
        # s is non ascii byte string
        return s.decode('unicode_escape')

TAG:

 

评分:0

我来说两句

Open Toolbar