更新时间:2023-11-11 16:51:52
Python 3 引入了函数注解.他们自己什么都不做,但您可以编写自己的执行:
Python 3 introduces function annotations. By themselves they don't do anything, but you can write your own enforcement:
def strict(fun):
# inspect annotations and check types on call
@strict
def funcA(a: int, b: int) -> int:
return a + b