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

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

相关推荐
liliangcsdn3 分钟前
如何使用lambda对python列表进行排序
开发语言·python
葱明撅腚14 分钟前
seaborn绘图(下)
python·matplotlib·可视化·seaborn·图表绘制
半路_出家ren18 分钟前
3.python模拟勒索病毒
python·网络安全·密码学·网络攻击模型·base64·病毒·勒索病毒
jhf202036 分钟前
2026汽车4S店GEO优化高性价比公司选型指南:从效果、成本到适配
python·汽车
叫我:松哥39 分钟前
基于scrapy的网易云音乐数据采集与分析设计实现
python·信息可视化·数据分析·beautifulsoup·numpy·pandas
极智-9961 小时前
GitHub 热榜项目-日榜精选(2026-01-24)| AI智能体工具、Python生态等 | remotion、VibeVoice、goose等
人工智能·python·github·ai智能体·大模型部署·语音ai
YMLT花岗岩1 小时前
Python学习之-函数-入门训练-具有多个返回值的函数
python·学习
北鹤M1 小时前
用MeteoStat计算任意时刻经纬度真实气象数据
人工智能·python
星瞳科技OpenMV1 小时前
星瞳OpenMV官方机械臂教程|从零开始:Robot Arm机械臂快速上手
arm开发·图像处理·python·计算机视觉·ai·机器人·openmv
写代码的【黑咖啡】1 小时前
Python中的lxml:高效XML处理库
xml·开发语言·python