【发布时间】:2020-01-12 01:22:16
【问题描述】:
我想有效地从我的字符串中删除所有符号。
x = hello!!
r = dict.fromkeys(map(ord, '\n ' + string.punctuation))
x.translate(r)
我希望这会删除所有符号,而不仅仅是句号 (.)
【问题讨论】:
-
符号是什么意思?你想只保留ascii-chars吗?只有字母和数字?
-
是的,我想保留字母和数字并删除所有其他字符,例如标点符号
标签: python python-3.x