2024-05-15 01:03:01 发布
网友
如果我有以下情况:
def alert(self, text: str, color: str) -> str:
我能得到指定类型的参数吗
我尝试使用func.__code__.co_varnames&inspect.getargspec(func)没有很好的效果
func.__code__.co_varnames
inspect.getargspec(func)
alert.__annotations__有一个类型为的dict
alert.__annotations__
键return描述返回值。所有其他键都是参数的名称
return
blue\u note的答案不适用于python3.7中引入的__future__.annotations,请改用typing.get_type_hints
__future__.annotations
alert.__annotations__
有一个类型为的dict键
return
描述返回值。所有其他键都是参数的名称blue\u note的答案不适用于python3.7中引入的
__future__.annotations
,请改用typing.get_type_hints相关问题 更多 >
编程相关推荐