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
"""

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

相关推荐
轻竹办公PPT1 小时前
2026 年工作计划汇报 PPT:AI 生成方案实测对比
人工智能·python·powerpoint
山土成旧客1 小时前
【Python学习打卡-Day42】打开深度学习“黑箱”:从Hook回调到Grad-CAM可视化
python·深度学习·学习
axinawang1 小时前
四、Python程序基础--考点--浙江省高中信息技术学考(Python)
python·浙江省高中信息技术
red润1 小时前
python win32COM 对象介绍调用Word、WPS 与应用生态
python
旦莫1 小时前
Python测试开发工具库:测试环境变量统一配置与加载工具
python·测试开发·自动化·ai测试
Hello.Reader1 小时前
Flink Avro Format Java / PyFlink 读写、Schema 细节与坑点总结
java·python·flink
我是海飞2 小时前
杰理 AC792N WebSocket 客户端例程使用测试教程
c语言·python·单片机·websocket·网络协议·嵌入式·杰理
shy^-^cky2 小时前
Python程序设计完整复习要点(含实例)
python·期末复习
做萤石二次开发的哈哈2 小时前
萤石开放平台 萤石可编程设备 | 设备脚本自定义开发
开发语言·python·萤石云·萤石·萤石开放平台