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

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

相关推荐
梅雅达编程笔记6 小时前
零基础学 Python 第14章 | 模块、包与第三方库
开发语言·python·django·numpy·pandas
Mr__Miss7 小时前
Java泛型完全指南:从入门到精通
java·开发语言·python
嘿丨嘿7 小时前
VLA 入门(六):VLA 如何进行强化学习后训练?
人工智能·python·深度学习·机器人
祉猷并茂,雯华若锦8 小时前
Appium 3.x实战:获取元素属性全解析
python·appium·自动化
宠友信息8 小时前
消息序号如何保证即时通讯源码聊天记录稳定加载
java·spring boot·redis·python·mysql·uni-app
小柯南敲键盘9 小时前
批量图片翻译与视频字幕一站式解决高效跨境电商沟通难题
大数据·人工智能·python·音视频
梅雅达编程笔记9 小时前
零基础学 Python 第15章 | 类与对象:面向对象编程入门
开发语言·python·django·numpy·pandas
smj2302_7968265211 小时前
解决leetcode第3989题网格中保持一致的最大列数
python·算法·leetcode
吴梓穆12 小时前
Python 基础 正则表达式
python
巧克力男孩dd12 小时前
Python超典型练习题(第一次作业)
开发语言·python·算法