我正在寻找一个正则表达式,我在文本中找到,单词“ata de audiência”或“termo de audiência”,找到“incocilia”、“reclamante”和“reclamada”,没有找到单词“sentença”
if(re.search(r'ata de audiência' or r'termo de audiência') and r'inconcilia' and r'reclamada' and r'reclamante' and not r'sentença', content.read())):
key_content = True
我试着这样做。。我可以找到单词,但是当我使用“AND NOT”操作符时,正则表达式不起作用
附言:有葡萄牙语单词
问题中的代码不够完整,无法详细注释,但第一个问题是误解了传递给
re.search()
的参数。你知道吗以下代码是布尔表达式:
Python将其解释为“使用第一个字符串,如果不是无或非空,则使用第二个”。你知道吗
在控制台上:
与
and
和not
类似:您需要提供一个独立的小示例。通常情况下,准备这个例子会让你有很长的路来回答这个问题。你知道吗
你不需要正则表达式。你知道吗
正则表达式不是这样工作的。如果你真的想用的话,我建议你多看看。你知道吗
对于您的需要,
in
关键字更合适。如果子字符串在字符串中,则返回True
;如果子字符串不在字符串中,则返回False
。可以使用and
和or
命令链接这些子字符串,也可以执行以下操作:相关问题 更多 >
编程相关推荐