flag = None if isinstance(str_one,str): str_one = str_one.encode('unicode-escape').decode('utf-8') if str_two in str_one: flag = True else: flag = False
str_one的字段
'"status":90008'
str_two的字段
'{
"data": [],
"msg": "参数错误",
"status": 90008
}'
对应的比较代码(使用的是python3.6.5,所以没有decode(‘string-escape’)):
flag = None
if isinstance(str_one,str):
str_one = str_one.encode('unicode-escape').decode('utf-8')
if str_two in str_one:
flag = True
else:
flag = False
return flag