检查另一个字符串中是否存在多个字符串如何检查数组中的任何字符串是否存在于另一个字符串中?比如:a = ['a', 'b', 'c']str = "a123"if a in str:
print "some of the strings found in str"else:
print "no strings found in str"这段代码不起作用,只是为了展示我想要实现的目标。
3 回答

白板的微信
TA贡献1883条经验 获得超3个赞
any()
True
False
False
match = next((x for x in a if x in str), False)
matches = [x for x in a if x in str]
matches = {x for x in a if x in str}
matches = []for x in a: if x in str and x not in matches: matches.append(x)
添加回答
举报
0/150
提交
取消