Python 字符串去掉标点符号最佳实践
方法一:
str.isalnum
:
S.isalnum() -> bool
Return True if all characters in S are alphanumeric and there is at least one character in S, False otherwise.
1 | "Special $#! characters spaces 888323" string = |
特点:
方法二:
string.punctuation
1 | import re, string |
方法三:
re
1 | import re |
测时:
1 | import re, string, timeit |