使用规则替代工具re.sub re.sub import re line = re.sub('[!@#$]', '', line) 参考 Remove specific characters from a string in python