2024-04-24 03:02:16 发布
网友
Possible Duplicate:Check if multiple strings exist in another stringCheck to ensure a string does not contain multiple values
伙计们。如果我有
example = "1", "2", "3"
我该如何检查是否有任何项在字符串中。
一个例子:
>>> example = "1", 2, "3" >>> str in [type(entry) for entry in example]
如果元组中有str,则返回True。
使用^{}:
if any(s in some_string for s in example): # at least one of the elements is a substring of some_string
一个例子:
如果元组中有str,则返回True。
使用^{} :
相关问题 更多 >
编程相关推荐