我有一个这样的字符串:如何使用python从文本中删除特定的符号?
字符串=“这是我2013年2月11日的文字,&它包含了这样的人物! (例外)'
这些是我想要从我的字符串中删除的符号。
!, @, #, %, ^, &, *, (,), _, +, =, `,/
我曾尝试是:
listofsymbols = ['!', '@', '#', '%', '^', '&', '*', '(', ')', '_', '+', '=', '`', '/']
exceptionals = set(chr(e) for e in listofsymbols)
string.translate(None,exceptionals)
的错误是:
的整数需要
请帮我做这个!
http://stackoverflow.com/questions/3939361/remove-specific-characters-from-a-string- in-python 这可能是有用的! – 2013-03-08 06:32:14
@达达,感谢编辑:) – MHS 2013-03-08 07:30:24