我读到我可以通过使用名为 reveal_type
的函数来揭示变量的类型,但我找不到如何使用它或从哪里导入它。
最佳答案
我终于找到了如何使用它:你应该只在代码中放置和使用reveal_type
,然后用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 .
关于python - 如何在mypy中使用reveal_type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44625422/