似乎是个很好的用途
re.findall
>>> import re
>>> string = "This is a %(name)s example string %(foo)s I would like %(bar)s to extract all the placeholders from %(place)s"
>>> re.findall(r'%\((.+?)\)', string)
['name', 'foo', 'bar', 'place']
%\((.+?)\)
%(
,以下一个结尾
)
,捕获中间的所有内容。