我正在尝试使用以下代码:
try:
clean = filter(None, re.match(r'^(\S+) (.*?) (\S+)$', full).groups())
except TypeError:
clean = ""
但是我得到以下回溯......
Traceback (most recent call last):
File "test.py", line 116, in <module>
clean = filter(None, re.match(r'^(\S+) (.*?) (\S+)$', full).groups())
AttributeError: 'NoneType' object has no attribute 'groups'
解决此问题的正确异常/正确方法是什么?