我要声明正则表达式为r'塔塔.xnl.*-dev.1.0'中的list元素,它应该匹配tata.xnl.1.0-dev.1.0
,如何解决这个问题?。你知道吗
productline = '8.H.5'
pl_component_dict = {'8.H.5': [r'tata.xnl.*-dev.1.0','tan.xnl.1.0-dev.1.0'],
'8.H.7':['']
}
component_branch = "tata.xnl.1.0-dev.1.0"
if component_branch in pl_component_dict[productline] :
print "PASS"
else:
print "ERROR:Gerrit on incorrect component"
你知道吗错误:-你知道吗
ERROR:Gerrit on incorrect component
这里有一种使用^{} 的方法:
any
语句之所以有效,是因为re.search
要么返回布尔值为True的^{None
。你知道吗在字符串前面加
r
并不能使它成为正则表达式,而是使它成为raw string literal。你知道吗您需要使用
re.compile()
将它编译成正则表达式。你知道吗这个for else循环处理在
pl_component_dict[productline]
中有一个列表的事件,就像在本例中一样。你知道吗使编译的字典值
re
与您的字符串匹配:相关问题 更多 >
编程相关推荐