您发布的函数是有效的python 3.7。类型提示
added to Python in version 3.5.0
,您发布的代码应适用于3.5.0以后的任何版本:
Python 3.7.0 (default, Aug 22 2018, 20:50:05)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 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)
...
>>> success
<function success at 0x7fb70e4c61e0>
我怀疑您使用的是不支持这些语言功能的旧的Python版本。