Python Django RegExp错误

Python Django RegExp错误,python,regex,django,error-handling,Python,Regex,Django,Error Handling,我正在为我的博客设计搜索。这是我的停止词列表:stop|words=r”“\b(a | about | about | above | over | cross…)\b”““我一直得到这个回溯:无法使用编译模式处理flags参数有人知道为什么吗?如何重写:stop\u word\u list=re.compile(stop\u WORDS\u re,re.IGNORECASE)?编译时不传递re.IGNORECASE,使用时传递。请参阅。编译时不传递re.IGNORECASE,使用时传递。请参阅

我正在为我的博客设计搜索。这是我的停止词列表:stop|words=r”“\b(a | about | about | above | over | cross…)\b”““我一直得到这个回溯:无法使用编译模式处理flags参数有人知道为什么吗?如何重写:stop\u word\u list=re.compile(stop\u WORDS\u re,re.IGNORECASE)?

编译时不传递
re.IGNORECASE
,使用时传递。请参阅。

编译时不传递
re.IGNORECASE
,使用时传递。请参阅。

您没有显示此代码,但可能已经显示了

STOP_WORDS = r"""\b(a|about|above|across...)\b""" Cannot process flags argument with a compiled pattern stop_word_list = re.compile(STOP_WORDS_RE, re.IGNORECASE)
STOP_WORDS_RE = re.compile(STOP_WORDS)
某处

您想使用regex字符串将
re.IGNORECASE
传递到
re.compile
,在您的案例中
STOP\u WORDS
。因此:

# *not* STOP_WORDS_RE!
stop_word_list = re.compile(STOP_WORDS, re.IGNORECASE)

您没有显示此代码,但可能已经显示了

STOP_WORDS_RE = re.compile(STOP_WORDS)
某处

您想使用regex字符串将
re.IGNORECASE
传递到
re.compile
,在您的案例中
STOP\u WORDS
。因此:

# *not* STOP_WORDS_RE!
stop_word_list = re.compile(STOP_WORDS, re.IGNORECASE)