2024-06-24 12:26:08 发布
网友
python以什么方式定义(非类)类型,如:
typedef Dict[Union[int, str], Set[str]] RecordType
这就行了吗
from typing import Dict, Union, Set RecordType = Dict[Union[int, str], Set[str]] def my_func(rec: RecordType): pass my_func({1: {'2'}}) my_func({1: {2}})
此代码将在第二次调用my_func时从IDE生成警告,但在第一次调用时不会。正如@sahasrara62所指出的,这里有更多的信息https://docs.python.org/3/library/stdtypes.html#types-genericalias
my_func
这就行了吗
此代码将在第二次调用
my_func
时从IDE生成警告,但在第一次调用时不会。正如@sahasrara62所指出的,这里有更多的信息https://docs.python.org/3/library/stdtypes.html#types-genericalias相关问题 更多 >
编程相关推荐