python函数可以在参数列表的后面带有“-> expression” 形式的“返回值”注解。

函数可以在参数列表的后面带有“-> expression” 形式的“返回值”注解。
python的->类型形式,只是注解,并不是强制类型转换

def test(a: int) ->int:
    return a


print(test(False)) #结果还是False

 

猜你喜欢

转载自blog.csdn.net/weixin_43343144/article/details/87776809