在有->的情况下:
def f(ham: str, eggs: str = 'eggs') -> str:
print("Annotations:", f.__annotations__)
print("Arguments:", ham, eggs)
return ham + ' and ' + eggs
f('spam')
运行结果是:
# Annotations: {'ham':
# Arguments: spam eggs
def f(ham: str, eggs: str = 'eggs'):
print("Annotations:", f.__annotations__)
print("Arguments:", ham, eggs)
return ham + ' and ' + eggs
f('spam')
运行结果是:
Annotations: {'ham':
Arguments: spam eggs
总结:
其实没啥用,就是注释的作用,挺花哨的功能.