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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章