【发布时间】:2015-08-17 12:42:22
【问题描述】:
有一个这样的字符串:
mystr = 'account_id 37318 not found'
我想知道如何写一个条件比:
if 'account_id' not in str and 'not found' not in str:
doSomething()
我想一定有这样的:
if 'account_id' + %any substring% + 'not found' not in str:
doSomething()
也许正则表达式可能会有所帮助,但我不擅长使用它。
提前谢谢你。
【问题讨论】:
-
首先...
str是一个非常糟糕的变量名。 -
哦,是的,当然)这只是一个例子。我会编辑
标签: python regex string-matching