gpt4 book ai didi

python - 如何返回类型提示定义的类型

转载 作者:行者123 更新时间:2023-12-01 00:47:36 26 4
gpt4 key购买 nike

如果我有以下内容:

def alert(self, text: str, color: str) -> str:

我可以以某种方式获取我的参数的指定类型吗?

我尝试使用 func.__code__.co_varnamesinspect.getargspec(func) 但没有好的结果。

最佳答案

alert.__annotations__ 有一个包含类型的字典。

return描述了返回值。所有其他键都是参数的名称。

关于python - 如何返回类型提示定义的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56833503/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com