Python 判断列表中是否有元素被另一字符串包含

Python 判断列表中是否有元素被另一字符串包含

推荐阅读

all() 函数与 any() 函数

正文

python 复制代码
lst = ['das', 'it']
str1 = 'dasAuto'

if any(text in str1 for text in lst):
    print('The string contains at least one element from the list')
else:
    print('The string does NOT contain any of the elements in the list')
"""
result:
The string contains at least one element from the list
"""

如果大家觉得有用,就请点个赞吧~

相关推荐
Artech3 小时前
[对比学习LangChain和MAF-03]完全不同的Agent设计哲学
python·ai·langchain·c#·agent·maf
诸葛老刘4 小时前
国密python调java服务
java·python·国密·sm2
WL_Aurora4 小时前
Python 算法基础篇之排序算法(二):希尔、快速、归并
python·算法·排序算法
RSCompany4 小时前
Frida 17 以后 Python API 跑旧版 JS 报 Java is not defined ?一行 import 直接恢复 Frida 16 体验
开发语言·python·逆向·hook·frida·android逆向·frida17
张道宁4 小时前
从零开始训练YOLO手机检测模型:完整实战教程
python·yolo
快乐的哈士奇4 小时前
对话框打字机效果:Vur + Java/Python 实现
java·开发语言·python
malog_4 小时前
PyTorch图像数据加载实战指南
图像处理·人工智能·pytorch·python
博.闻广见4 小时前
AI_Python基础-4.标准库与IO
开发语言·python
程序猿编码4 小时前
大模型的“文字障眼法“:FlipAttack 文本反转越狱技术全解析
linux·python·ai·大模型
晚烛4 小时前
CANN 数据流与内存优化:L1/L2 缓存机制与计算重叠深度解析
人工智能·python·缓存