Last updated 2 years ago
容器基类列表:collections.abc — Python 文档
# def foo(ls: Union[List, Tuple]): def foo(ls: Sequence): ...
from typing import * # 判断能否 len(obj),即判断是否实现了 __len__ isinstance(obj, Sized) # 判断能否 obj[index] isinstance(obj, Sequence) # 判断某个类是否可以哈希 issubclass(cls, Hashable)