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.
这就是我所拥有的,但它不起作用:
p = re.compile(r'foo/(?P<id>\d)/') m = p.search('foo/234/')
为什么是m None?
m
None
您需要使用量词\d+而不是\d, 来匹配一个或多个数字:
\d+
\d
re.compile(r'foo/(?P<id>\d+)/')