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

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

相关推荐
满怀冰雪9 小时前
06-自动微分入门:用 Paddle 计算梯度
人工智能·python·深度学习·paddle
xlrqx15 小时前
家电清洗培训课程类别、培训方式及费用情况究竟有哪些
大数据·python
lbb 小魔仙15 小时前
VS Code Python 高级调试技巧:从入门到精通
开发语言·python
lzqrzpt15 小时前
LED驱动电源行业品牌格局与技术差异深度总结
python·单片机·嵌入式硬件
李可以量化15 小时前
PTrade 策略入门:before_trading_start 函数详解(上)—— 盘前准备逻辑全指南
python
大海变好AI15 小时前
AIGC分层推理落地能否串联多工具完成自动化闭环
人工智能·python·自动化·aigc
二宝哥16 小时前
14.Python模块与包完全指南:从定义到实战
python
三声三视16 小时前
交互式用够了?用 Agent SDK 把 Claude 塞进 Python Web 服务
人工智能·python·ai·aigc·ai编程
zhanghaha131417 小时前
Python语言基础:4_数据类型转换
java·前端·python
larance17 小时前
机器学习特征预处理之标准化/归一化
开发语言·python·机器学习