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

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

相关推荐
fbincon4 小时前
Claude Code 自定义状态栏工具:安装、配置与 Subagent 状态展示
python·typescript·claude·claude-code·statusline
yunfengzhineng4 小时前
天津立体库货架配套厂家
大数据·运维·人工智能·python
m0_674571975 小时前
力扣 hot 100 python
python·算法·leetcode
小白快快跑哦5 小时前
python-字符串全解(六):正则表达式-元字符与转义
python·正则表达式·字符串·元字符·转义
Want5955 小时前
Python炫酷烟花①
开发语言·python
青少儿编程课堂6 小时前
蓝桥杯+全国青少年信息素养大赛+电子学会PythonC/C++考级:最长公共子序列LCS解析
c++·python·算法·bfs·信息学竞赛
Y3815326626 小时前
印度电商数据采集教程:用 SerpBase 查 Flipkart/Myntra/Ajio 商品(附代码)
数据库·python
阿维的博客日记6 小时前
大白话解析快排Python
python
doujiaozh6 小时前
我在 DOS 6.22 上跑通了 Kimi AI:一场跨越 40 年的硬核接力
python
凛铄linshuo7 小时前
分析业务流程什么时候适合断言?
python·pytest