37,719
社区成员
发帖
与我相关
我的任务
分享
list5="hello,can you hear me?"
import re
from string import punctuation
a=re.split(r'\W+', list5.strip(punctuation))
print(a)
for i in range(len(a)):
print(a[i])
list5 = "hello, can you hear me?"
>>> from string import punctuation
>>> re.split(r'\W+', list5.strip(punctuation))
['hello', 'can', 'you', 'hear', 'me']
>>> re.findall(r'(\w+)', list5)
['hello', 'can', 'you', 'hear', 'me']