首先,我知道有人问过它here,但它确实很旧,所以这个bug可能会被修复。我的问题是:
我正在编写一个程序来删除字符串中的所有符号。这是我的密码:
text = input("Enter some text ")
symbols = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '|', '[', ']', ':', '\\', '"', ';', "'", '<', '>', '?', ',', '.', '/']
text = re.sub("|".join(symbols), "", text)
print(text)
当我运行这个时,我得到re.error: nothing to repeat at position 14
。有人知道怎么解决这个问题吗
目前没有回答
相关问题 更多 >
编程相关推荐