Python def longestPalindrome,self, s: str -> str: 函数功能注释 annotations

https://www.cnblogs.com/hongten/p/hongten_python_function_annotation.html

def f(ham: 42, eggs: int = 'spam') -> "Nothing to see here":
    print("Annotations:", f.__annotations__)
    print("Arguments:", ham, eggs)

#def关键字定义了函数f,在函数f中有两个参数:ham,eggs。
#其中ham没有默认值,而eggs是由默认值的,其默认值为'spam'.
#参数ham的注释部分为:42;参数eggs的注释部分为:int
# "Nothing to see here"是返回值的注释,这个必须用 '->'连接

#看了java代码后,你会有更直观的认识,注释嘛,你可以根据你自己的想法,想怎么写就怎么写,如42,int;不过不好的注释有时候会给别人阅读代码带来很大的麻烦

#如果上面的代码是这样写:
def f(ham: int = 42, eggs: str = 'spam') -> 'Nothing to see here':
    print("Annotations:", f.__annotations__)
    print("Arguments:", ham, eggs)

#我想很多人阅读代码的时候就很容易理解啦