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

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

相关推荐
智算菩萨12 分钟前
OpenCV色彩空间转换实战:BGR转HSV/LAB的工业应用场景详解(含自动化脚本)
人工智能·python·opencv·计算机视觉·自动化·音视频
曲幽14 分钟前
别再数据线了!用FastAPI 5分钟搭个局域网文件+剪贴板神器
python·fastapi·web·async·clipboard·fileupload
AbsoluteLogic17 分钟前
Python——必学内置模块 OS
python
sqyno1sky21 分钟前
游戏与图形界面(GUI)
jvm·数据库·python
用户83562907805126 分钟前
Python 实现 Word 文档图片插入与排版技巧
后端·python
2501_9454235435 分钟前
持续集成/持续部署(CI/CD) for Python
jvm·数据库·python
m0_6214385235 分钟前
用Python实现自动化的Web测试(Selenium)
jvm·数据库·python
2301_8042154143 分钟前
Python多线程与多进程:如何选择?(GIL全局解释器锁详解)
jvm·数据库·python
大鹏说大话1 小时前
Java 并发基石:CAS 原理深度解析与 ABA 问题终极解决方案
开发语言·python
2301_793804691 小时前
Python单元测试(unittest)实战指南
jvm·数据库·python