你的abbasong.replace语句有问题。遇到此类问题,最好先咨询口译员的帮助:replace(self, old, new, count=-1, /) Return a copy with all occurrences of substring old replaced by new. count Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.第三个参数需要是一个整数。它不能是空字符串""。这也是回溯所说的:Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: 'str' object cannot be interpreted as an integer如果你把一个整数放在那里,它就会像你期望的那样工作。但如果你面对Syntax Error,它可能在print声明中。Python3 使用,print()而 Python2 使用print. 尝试更改此语句。但是,大写和小写字符之间也存在差异。“D”与“d”不同,因此removed在您的情况下为空。