小编Mic*_*ein的帖子

为什么List [str]不是Sequence [str]的子类

List是以下的子类Sequence:

>>> from typing import List, Sequence
>>> issubclass(List, Sequence)
True
Run Code Online (Sandbox Code Playgroud)

但List[str]不是以下的子类Sequence[str]:

>>> issubclass(List[str], Sequence[str])
False
Run Code Online (Sandbox Code Playgroud)

为什么?

python type-hinting python-3.x

11
推荐指数
1
解决办法
180
查看次数

标签 统计

python ×1

python-3.x ×1

type-hinting ×1