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

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

相关推荐
避避风港34 分钟前
Java 抽象类
java·开发语言·python
武子康2 小时前
Java-168 Neo4j CQL 实战:WHERE、DELETE/DETACH、SET、排序与分页
java·开发语言·数据库·python·sql·nosql·neo4j
天地之于壹炁兮2 小时前
元素认证的智慧:Python分支魔法的艺术与禁忌
windows·python
闲人编程2 小时前
Python与大数据:使用PySpark处理海量数据
大数据·开发语言·分布式·python·spark·codecapsule·大规模
daqinzl2 小时前
Ubuntu 使用 Python 启动 HTTP 服务
python·ubuntu·http server 服务
qunshankeji3 小时前
交通事故自动识别_YOLO11分割_DRB实现
python
小呀小萝卜儿3 小时前
2025-11-14 学习记录--Python-特征归一化方法(Min-Max或StandardScaler)
开发语言·python·学习
顾安r3 小时前
11.14 脚本网页 青蛙过河
服务器·前端·python·游戏·html
测试19983 小时前
如何用Appium实现移动端UI自动化测试?
自动化测试·软件测试·python·测试工具·ui·职场和发展·appium
Python私教3 小时前
第一个Python金融爬虫
爬虫·python·金融