如 判断str是否包含str_list中的元素
str = "this is string example....wow!!!" str_list = ['aa','bb','str','ex'] flag = all( i in str for i in str_list) #用any(),或者all()函数判断是否包含,返回值为bool值,前面加一个int(any()) 可返回1或者0 flag2 = int(all( i in str for i in str_list) ) print(flag) print(flag2)
返回值
False
0