技术栈

Python 判断列表中是否有元素被另一字符串包含

勤奋的大熊猫2024-01-26 23:49

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

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

上一篇:华为AC+FIT AP组网配置
下一篇:extern “C“
相关推荐
ZhengEnCi
1 小时前
M3-markconv库找不到wkhtmltopdf问题
python
2301_76444133
4 小时前
LISA时空跃迁分析,地理时空分析
数据结构·python·算法
chushiyunen
5 小时前
python rest请求、requests
开发语言·python
cTz6FE7gA
5 小时前
Python异步编程:从协程到Asyncio的底层揭秘
python
baidu_huihui
5 小时前
在 CentOS 9 上安装 pip(Python 的包管理工具)
开发语言·python·pip
南 阳
5 小时前
Python从入门到精通day63
开发语言·python
lbb 小魔仙
5 小时前
Python_RAG知识库问答系统实战指南
开发语言·python
FreakStudio
6 小时前
MicroPython LVGL基础知识和概念:底层渲染与性能优化
python·单片机·嵌入式·电子diy
素玥
6 小时前
实训5 python连接mysql数据库
数据库·python·mysql
热门推荐
01GitHub 镜像站点02一周AI热点速览(2026.03.31-04.06):GPT-6曝光、谷歌开源Gemma 4、资本狂飙与模型军备竞赛03OpenClaw 请求超时 llm request timed out 怎么解决?3 种方案实测,附完整排查流程04VMware Workstation Pro 17 虚拟机完整安装教程(2026最新)05AI 编程效率翻倍:Superpowers Skills 上手清单 + 完整指南06基于 Docker 部署 Hermes Agent 并接入飞书机器人的完整指南07UV安装并设置国内源08实测!Gemma 4 成功跑在安卓手机上:离线 AI 助手终于来了09Oh My Codex 快速使用指南10CodeBuddy与WorkBuddy深度对比:腾讯两款AI工具差异及实操指南