Python 函数注释写法
def testDef(x:int, y: "string"="test") -> "return information":
"""There is a test for explain of function"""
pass
print(testDef.__annotations__) # 打印函数注释
help(testDef)
"""
output:
{'x': <class 'int'>, 'y': 'string', 'return': 'return information'}
Help on function testDef in module __main__:
testDef(x: int, y: 'string' = 'test') -> 'return information'
There is a test for explain of function
"""
Reference: