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.
s = "hello cats" print(re.search(r"hello",s).groups())
这打印()。
()
根据文档,如果未找到匹配项,则 groups() 返回一个空元组。那么为什么不匹配呢?
groups返回匹配的组。您没有定义任何:
groups
s = "hello cats" print(re.search(r"(he)l(lo)",s).groups())
印刷('he', 'lo')
('he', 'lo')