
刚看才了一个视频,其中一个镜头是一段 Python 程序,函数名后面有个箭头,记得见过但没去了解过(懒),一直觉得程序上面有几个箭头可以提高逼格,遂去了解了一下:
叫做:return annotation
(返回注释/函数返回类型)
funcdef: 'def' NAME parameters ['->' test] ':' suite
def f(x) -> int:
return x
def f(x):
return x


刚看才了一个视频,其中一个镜头是一段 Python 程序,函数名后面有个箭头,记得见过但没去了解过(懒),一直觉得程序上面有几个箭头可以提高逼格,遂去了解了一下:
叫做:return annotation
(返回注释/函数返回类型)
funcdef: 'def' NAME parameters ['->' test] ':' suite
def f(x) -> int:
return x
def f(x):
return x
本文标题:Python函数名后跟的 -> 有什么用
本文链接:https://www.haomeiwen.com/subject/rybuxktx.html
网友评论