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

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

相关推荐
梦幻精灵_cq9 小时前
sumdir——一个伪python.built-in的“术法”打造
python
weixin_4407305010 小时前
函数return、参数、参数组、递归函数、高阶函数等小结
开发语言·python
天赐范式10 小时前
天赐范式第181天:让视图开始切换——PBFT视图切换与从safety到liveness的跨越
python·pbft·数字生命·天赐范式·动态运行时·拜占庭容错
sugarzhangnotes11 小时前
【无标题】
开发语言·人工智能·python
weixin_4471952911 小时前
【无标题】
pytorch·python
迅猛龙办公室11 小时前
Python实现简单的人名对话
python
阿坨12 小时前
firestart:一行命令启动你的日常应用和网页
python·pypi·cli·click
老歌老听老掉牙12 小时前
麻花钻切屑形态演变的力学机制与临界条件分析
python·算法·钻头
happylifetree13 小时前
Python18(补充):练习
python
weixin_4166679613 小时前
银河麒麟V10看门狗试验-1
网络·chrome·python