快速尝试代码行并使用 visual studio 代码中的变量

quickly try line of code and work with variables in visual studio code

我比较习惯Spyder,对vsc很陌生。在 Spyder 中,您有一个 python 控制台,您可以在其中快速尝试代码片段,例如:

print(len(a))

无需 运行 整个代码。 在 vsc 中也可以吗?我什么都没看到。

另外,我只能在调试模式下看到变量。在 Spyder 中,我手边有一个 运行 之后的所有变量,并且可以尝试使用它们进行动态试验。是否有另一个 Variable-viewer 插件或如何启用它?

您可以使用 this extensions of python. It has a Jupyter Notebook feature that comes with a variable explorer. It is recommended to also add the Jupyter extension as well (they work together just fine), you can find it here.

您可以阅读 this documentary 关于如何通过 visual studio 代码使用 Jupyter,您可以看到它显示了如何按照您想要的方式显示变量。