考虑到 Python Docstyping为什么下面的代码不起作用?
>>> Vector = list[float]
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'type' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)
在文档中有与我上面提到的相同的例子。这里
Vector = list[float]
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]
Run Code Online (Sandbox Code Playgroud)
我没有发现有关此示例的问题。