Shr*_*rmn -1 python algorithm
我想知道如何删除一个或多个单词末尾和开头的标点符号。如果单词之间有标点符号,我们不会删除。
例如
输入:
word = "!.test-one,-"
输出:
word = "test-one"
Eps*_*i95 6
使用strip
strip
>>> import string >>> word = "!.test-one,-" >>> word.strip(string.punctuation) 'test-one'
归档时间:
2 年,10 月 前
查看次数:
263 次
最近记录: