7.3 给函数参数增加元信息
问题
解决方案
def add(x:int, y:int) -> int:
return x + y讨论
>>> add.__annotations__
{'y': <class 'int'>, 'return': <class 'int'>, 'x': <class 'int'>}Last updated
def add(x:int, y:int) -> int:
return x + y>>> add.__annotations__
{'y': <class 'int'>, 'return': <class 'int'>, 'x': <class 'int'>}Last updated