python 去除字符串里所有标点符号
import re
text = " Hello,. [world]! ()!"
#r='[’!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~]+'
r='[’!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~\n。!,]+'
line=re.sub(r,'',text)
print(line)
Hello world
import re
text = " Hello,. [world]! ()!"
#r='[’!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~]+'
r='[’!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~\n。!,]+'
line=re.sub(r,'',text)
print(line)
Hello world