2024-06-08 13:01:02 发布
网友
我´我是一个没有编程经验的网络工程师,最近用的是python,但每天都在做一些小的改进
我需要一些帮助来获取IF语句中的多个匹配项,例如:
if "access-class 30" in output and "exec-timeout 5 5" in output: print ('###### ACL VTY OK!!! ######')
是否可以在一个字符串中检查多个关键字? 谢谢你的时间
对生成器表达式使用all函数:
all
data = ["access-class 30", "exec-timeout 5 5"] if all(s in output for s in data): print('###### ACL VTY OK!!! ######')
是的,这是可能的
可以使用正则表达式(Regex)
import re li = [] # List of all the keywords for l in li for m in re.finditer(l,output) if m !=None: print 'match found'
对生成器表达式使用
all
函数:是的,这是可能的
可以使用正则表达式(Regex)
相关问题 更多 >
编程相关推荐