最近,我遇到了“->”在Python3中,当研究函数声明时,这意味着什么?到目前为止,除了Javascript函数声明之外,我从未见过这样的声明。
def f(self, s: 'str') -> 'bool': pass
这是函数返回值类型的注释。
def sum()->表达方式:
https://www.python.org/dev/peps/pep-3107/
根据 python docs 与打字有关。
功能,用于指定 回来 python中的函数类型