注意这一次测试的路径是在:
C:\Python27\Lib\site-packages\robotframework-3.0.4-py2.7.egg\robot\utils
1、在Utils 的py文件里面导入 import json
2、修改代码
在if PY2:里面
注意python的格式
def unic(item):
if isinstance(item, unicode):
return item
if isinstance(item, (bytes, bytearray)):
try:
return item.decode('ASCII')
except UnicodeError:
return u''.join(chr(b) if b < 128 else '\x%x' % b
for b in bytearray(item))
if isinstance(item, (list, dict, tuple)):
try:
item = json.dumps(item, ensure_ascii=False, encoding='cp936')
except UnicodeDecodeError:
try:
item = json.dumps(item, ensure_ascii=False, encoding='cp936')
except:
pass
except:
pass
try:
try:
return unicode(item)
except UnicodeError:
return unic(str(item))
except:
return _unrepresentable_object(item)