小编roz*_*mir的帖子

键入库中的示例代码导致 TypeError: 'type' object is not subscriptable,为什么?

考虑到 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)

我没有发现有关此示例的问题。

python typing

4
推荐指数
1
解决办法
344
查看次数

标签 统计

python ×1

typing ×1