输入字符串如下:
line = "Cat Jumped the Bridge"
Run Code Online (Sandbox Code Playgroud)
输出应该是"跳过桥".
我试过了
s2 = re.match('\W+.*', line).group()
Run Code Online (Sandbox Code Playgroud)
但它回来了
Traceback (most recent call last):
File "regex.py", line 7, in <module>
s2 = re.match('\W+.*', line).group()
AttributeError: 'NoneType' object has no attribute 'group'
Run Code Online (Sandbox Code Playgroud)
显然这场比赛失败了.
谢谢你的任何建议.乔
python-2.7 ×1