python 自定义断言
2020-12-08 12:54
标签:family except else exce instance pytho color 定义 pass python 自定义断言 标签:family except else exce instance pytho color 定义 pass 原文地址:https://www.cnblogs.com/xiaozeng6/p/10992242.html #判断返回结果是否包含预期结果
def is_contain(self,str_one,str_two):#判断str_one是否包含于str_two
flag=None
try:
str_one.index(str_two)>1
except:
print(‘PASS!‘)
flag=False
return flag
#判断两个字典是否相等
def is_equal_dict(self,dict_one,dict_two):#判断两个字典值是否相等
if isinstance(dict_one,dict_two):
print(‘haha‘)
dict_one =json.loads(dict_one)#str转成dict
print(dict_two)
else:
print(‘oo‘)
print(operator.eq(dict_one,dict_two))
上一篇:java web开发常用的代码
下一篇:深入理解Spring IoC