1

我有以下设置:

from typing import List
a = List[int]
foo(a) == int

foo可以用什么来int摆脱List

4

1 回答 1

1

您可以使用该属性__args__来取出int.

from typing import List
a = List[int]
print(a.__args__[0])

结果:<class 'int'>

于 2021-06-30T22:17:36.037 回答