摆脱SyntaxError:Python中的语法无效

mes*_*lds 3 python python-2.7

def success(self, input1: str = "", input2: str = "", input3: str = "") -> None:
E                               ^
E   SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

不知道这里发生了什么..

码:

 def success(self, input1: str = "", input2: str = "", input3: str = "") -> None:
        input1 = str(input1)
        input2 = str(input2)
        input3 = str(input3)
        print(Color.BOLD + Color.GREEN + " " + Color.CHECKMARK + " " + input1 + Color.END + " " + input2 + " " + input3)
Run Code Online (Sandbox Code Playgroud)

Pru*_*une 5

由于您使用的是Python 2.7,因此需要备份该语法。类型提示是Python 3;删除它们。

def success(self, input1="", input2="", input3=""):
Run Code Online (Sandbox Code Playgroud)