typing 是在 python 3.5 才有的模块
Python 类型提示:https://www.cnblogs.com/poloyy/p/15145380.html
https://www.cnblogs.com/poloyy/p/15150315.html
https://www.cnblogs.com/poloyy/p/15153883.html
https://www.cnblogs.com/poloyy/p/15153886.html
https://www.cnblogs.com/poloyy/p/15154008.html
https://www.cnblogs.com/poloyy/p/15154196.html
https://www.cnblogs.com/poloyy/p/15158613.html
https://www.cnblogs.com/poloyy/p/15170066.html
可选类型
# 可选参数 def foo(arg: int = 0) -> None: ... # 不传 arg 默认取 0 foo()
def foo_func(arg: Optional[int] = None): print(arg) foo_func() foo_func(1) # 输出结果 None 1
def foo_func(arg: int = None): print(arg) foo_func() foo_func(1) # 输出结果 None 1
这种写法,Pycharm 并不会 warning