从字符串中删除标点符号的最佳方法

旧时模样 提交于 2020-08-11 17:11:50

问题:

It seems like there should be a simpler way than: 似乎应该有一个比以下方法更简单的方法:

import string
s = "string. With. Punctuation?" # Sample string 
out = s.translate(string.maketrans("",""), string.punctuation)

Is there? 在那儿?


解决方案:

参考一: https://stackoom.com/question/17Bg/从字符串中删除标点符号的最佳方法
参考二: https://oldbug.net/q/17Bg/Best-way-to-strip-punctuation-from-a-string
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!