async def fetch(self, url: str, keys: object, repeat: int) -> (int, object):
dosomething()
return None
I found such a statement when I was looking at other people's programs. I checked many places but couldn't find any explanation about "->".
The most similar ones found are arrow functions, but they look different.
What symbol is this? Or where should I check?
世界只因有你2017-05-18 11:02:48
Function annotations ?
"Python 3 provides syntax to attach metadata to the parameters of a function declaration
and its return value."
某草草2017-05-18 11:02:48
Stackoverflow has it.
What does -> mean in Python function definitions?
Python 3 extends the feature by allowing you to attach metadata to functions describing their parameters and return values.
Simply put -> It is to tell the user the specific parameters and parameter types.
For details, please see: PEP3107
https://www.python.org/dev/pe...
高洛峰2017-05-18 11:02:48
Just prompt the function’s input parameters and return value数据类型
Easy for programmers to read code.
ringa_lee2017-05-18 11:02:48
http://python3-cookbook.readt...
The python cookbook has a detailed description. It is recommended to read this book when you have time. It is still very helpful.
phpcn_u15822017-05-18 11:02:48
This is a type hint that has been officially included since python3.5. It marks the type of variables. For IDEs supported by pycharm, it can provide more accurate code hints and variable inspections.
For specific usage, please see https://docs.python.org/3/lib...