python
中有很多奇怪的概念,语法很丑陋。若是论起简洁和优雅,python
不及shell
的万一。
def func(a: 'spam') -> int:
print(a)
return 3
def foo(a: 'spam' = 8) -> int:
print(a)
return 3
以上两个函数就是给参数和返回值添加了注解,可以说毫无实际意义。然后通过print(func.__annotations__)
可以查看注解的内容:
{‘a’: ‘spam’, ‘return’: