函数“-> str”的含义

Gou*_*abo 1 python

def f(ham: str, eggs: str = 'eggs') -> str:
    print("Annotations:", f.__annotations__)
    print("Arguments:", ham, eggs)
    return ham + ' and ' + eggs
Run Code Online (Sandbox Code Playgroud)

在上面的代码块中,来自https://docs.python.org/3.5/tutorial/controlflow.html#documentation-strings

我的问题是关于-> str上面的代码块中的。它有什么作用 ?

Han*_*ans 8

它指定返回值。它与代码完全无关,仅用于文档目的。