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

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

相关推荐
AI行业学习7 分钟前
CC-Switch v3.16.1 官方下载 | 安装配置详细教程【2026.6.10】
java·开发语言·vue.js·python·mysql·eclipse·html
早起CaiCai32 分钟前
【Pytorch 实践1】手写数字
人工智能·pytorch·python
吴梓穆44 分钟前
Python 语法基础 函数
开发语言·python
Kobebryant-Manba1 小时前
学习文本处理
开发语言·python
m0_617493941 小时前
PaddleOCR报错:OneDnnContext does not have the input Filter 解决方案汇总
python
李可以量化1 小时前
量化迅投 QMT vs 聚宽 (JoinQuant)全面分析
python·量化·qmt·ptrade·聚宽
旅僧1 小时前
运行UMI镜像
python
ellenwan20261 小时前
期货跨期价差程序化怎么做:天勤 SP 合约与腿比例核对
python·区块链
月疯1 小时前
torch:expand和repeate的区别
开发语言·python·深度学习
顾林海2 小时前
Agent入门阶段-编程基础-Python:Python 开发环境与运行方式
python·agent·ai编程