使用
re.findall():
In [5]: import reIn [8]: strs = "{foo} spam eggs {bar}"In [9]: re.findall(r"{(w+)}", strs)Out[9]: ['foo', 'bar']
使用
re.findall():
In [5]: import reIn [8]: strs = "{foo} spam eggs {bar}"In [9]: re.findall(r"{(w+)}", strs)Out[9]: ['foo', 'bar']