报错脚本内容:
# -*- coding:utf-8 -*- import html class OutputResult(): def __init__(self,fretMsg): self.fretMsg = fretMsg #将fretMsg反转义,也就是报错部分 def plainTextToHtml(self): self.fretMsg1 = html.unescape(self.fretMsg) return self.fretMsg1
报错原因解析:Python的JSR223 Sampler中选择的语言是“jython2.7.2”,不支持Python3中的反转义方法
解决方法:脚本改成以下内容
import HTMLParser #python2的反转义方法在此模块中 class OutputResult(): def __init__(self,fretMsg): self.fretMsg = fretMsg #将fretMsg反转义处理 def plainTextToHtml(self): self.fretMsg1 = HTMLParser.HTMLParser().unescape(self.fretMsg) return self.fretMsg1