2024-09-28 17:21:19 发布
网友
我读过,我可以通过使用一个名为reveal_type的函数来显示变量的类型,但是我找不到如何使用它或从何处导入它。在
reveal_type
最后我发现了如何使用它:您应该在代码中放入并使用reveal_type,然后用mypy程序运行它。然后,它将记录一条如下所示的消息:
mypy
Revealed type is 'builtins.str*'
来自mypy文档:
reveal_type is only understood by mypy and doesn’t exist in Python, if you try to run your program. You’ll have to remove any reveal_type calls before you can run your code. reveal_type is always available and you don’t need to import it.
更多阅读:here。在
最后我发现了如何使用它:您应该在代码中放入并使用
reveal_type
,然后用mypy
程序运行它。然后,它将记录一条如下所示的消息:来自
mypy
文档:更多阅读:here。在
相关问题 更多 >
编程相关推荐