PUNCT_CHARS = { '(', ')', ',', ',', '、', ':', ':', '[', ']', '#'}
words = ['a', '#good', 'student']
for word in words.copy():
for char in PUNCT_CHARS:
if char in word:
words.remove(word)
break
print(words)
['a', 'student']
我想删除包含标点符号的单词.第二个for循环是否可以替换为"any"或"all"函数以提高效率?