Py中的类型注解【转载】

转自:https://docs.python.org/zh-cn/3/library/typing.html

#一个典型的函数注释例子,为参数加上了类型
def greeting(name: str) -> str:
    return 'Hello ' + name

 以前只能通过注释来说明变量类型。

可以简化一些类型说明的过程。

猜你喜欢

转载自www.cnblogs.com/BlueBlueSea/p/10951370.html