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

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

相关推荐
卷无止境17 小时前
智能体开发环境ADE浅析,编程工具的下一次范式跃迁
后端·python
2601_9623008121 小时前
机器学习贴士:使用Python编写MapReduce
hadoop·python·机器学习·mapreduce·数据处理
xyz_CDragon1 天前
GitHub上4个爆款AI开源Skill:拍照后不用P图,用Codex一键生成高级海报(附效果图+使用教程)
人工智能·python·github·codex·skill
weixin199701080161 天前
[特殊字符]《跨境二手ERP对接Back Market:标准化API + 7~10工作日技术合规审核实录》(附Python源码)
开发语言·python·pandas
持敬chijing1 天前
Python-数据类型-列表
开发语言·python·青少年编程
2601_962301011 天前
Python环境搭建及PyCharm破解使用技巧
python·pycharm·环境搭建·避坑技巧·破解使用
2601_962099461 天前
Python中的find()函数:用法和示例
python·字符串·索引·子字符串·find函数
大圣编蚕1 天前
Java StringWriter 详解:从入门到实战
java·开发语言·python
for_ever_love__1 天前
python基础语法学习: requirements.txt
开发语言·python·学习
程序员清风1 天前
FastAPI 入门:用 Python 快速开发现代后端服务
python·oracle·fastapi