Stripping everything but alphanumeric chars from a string in Python

问题:

What is the best way to strip all non alphanumeric characters from a string, using Python?使用 Python 从字符串中去除所有非字母数字字符的最佳方法是什么?

The solutions presented in the PHP variant of this question will probably work with some minor adjustments, but don't seem very 'pythonic' to me.这个问题PHP 变体中提出的解决方案可能会进行一些小的调整,但对我来说似乎不是很“pythonic”。

For the record, I don't just want to strip periods and commas (and other punctuation), but also quotes, brackets, etc.作为记录,我不仅想去掉句号和逗号(和其他标点符号),还要去掉引号、括号等。


解决方案:

参考一: https://en.stackoom.com/question/5M8y
参考二: https://stackoom.com/question/5M8y
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章