所以伙计们.如果我有
example = "1", "2", "3"
Run Code Online (Sandbox Code Playgroud)
我如何检查是否有任何项目在字符串中.
And*_*ark 18
用途any()
:
if any(s in some_string for s in example):
# at least one of the elements is a substring of some_string
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7810 次 |
最近记录: |