📌  相关文章
📜  python 删除标点符号 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:14.729000             🧑  作者: Mango

代码示例5
import string 
sentence = "Hey guys !, How are 'you' ?"
no_punc_txt = ""
for char in sentence:
   if char not in string.punctuation:
       no_punc_txt = no_punc_txt + char
print(no_punc_txt);                 # Hey guys  How are you 
# or:
no_punc_txt = sentence.translate(sentence.maketrans('', '', string.punctuation))
print(no_punc_txt);                 # Hey guys  How are you