Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将正则表达式定义为,IGNORECASE并且点将匹配所有。 以下代码:
IGNORECASE
str = "Test " a = re.findall(r"(\w+)", str, re.IGNORECASE, re.S)
得到错误
TypeError: findall() takes at most 3 positional arguments (4 given)
可以通过按位 OR-ing 来指定多个标志;例如,re.I | re.M同时设置I和标志。M
re.I | re.M
I
M
所以,按位或标志:
str = "Test " a = re.findall(r"(\d+)", str, re.IGNORECASE|re.S)