可能重复:
Check if multiple strings exist in another string
Check to ensure a string does not contain multiple values
所以伙计们。如果我有
example = "1", "2", "3"
我如何检查字符串中是否有任何项目。
答案 0 :(得分:18)
使用any()
:
if any(s in some_string for s in example):
# at least one of the elements is a substring of some_string
答案 1 :(得分:-1)
一个例子:
>>> example = "1", 2, "3"
>>> str in [type(entry) for entry in example]
如果元组中有str,将返回True。