0

首先,我知道这里有人问过它,但它真的很旧,所以这个错误可能会被修复。这是我的问题:

我正在编写一个程序来删除字符串中的所有符号。这是我的代码:

text = input("Enter some text ")
symbols = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '|', '[', ']', ':', '\\', '"', ';', "'", '<', '>', '?', ',', '.', '/']
text = re.sub("|".join(symbols), "", text)
print(text)

当我运行它时,我得到re.error: nothing to repeat at position 14. 有人知道如何解决这个问题吗?

4

0 回答 0