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

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

代码示例3
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