请解释 -> Vector: in python
Please explain -> Vector: in python
如何解释 -> Vector: in Python
这在python
中是什么意思
from typing import List
Vector = List[float]
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]
# typechecks; a list of floats qualifies as a Vector.
new_vector = scale(2.0, [1.0, -4.2, 5.4])
其函数注解:PEP 3107 -- Function Annotations。
也看看这个post:What does -> mean in Python function definitions?
如何解释 -> Vector: in Python
这在python
中是什么意思from typing import List
Vector = List[float]
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]
# typechecks; a list of floats qualifies as a Vector.
new_vector = scale(2.0, [1.0, -4.2, 5.4])
其函数注解:PEP 3107 -- Function Annotations。 也看看这个post:What does -> mean in Python function definitions?