Visual Studio代码交互式Python控制台 [英] Visual studio code interactive python console

查看:99
本文介绍了Visual Studio代码交互式Python控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有DonJayamanne python扩展名的Visual Studio代码.它工作正常,但我希望像Matlab中那样进行交互式会话,在该会话中,代码执行后,每个定义和计算结果都可以在控制台中访问.

I'm using visual studio code with DonJayamanne python extension. It's working fine but I want to have an interactive session just like the one in Matlab, where after code execution every definition and computational result remains and accessible in the console.

例如,运行以下代码后:

For example after running this code:

a = 1

python会话已终止,我无法在控制台中输入类似以下内容的

the python session is terminated and I cannot type in the console something like:

b = a + 1
print(b)

我知道python会话可以通过"-i"标志保持活动状态.但这根本行不通.

I'm aware that the python session can stay alive with a "-i" flag. But this simply doesn't work.

此外,每次我运行代码文件时,都会产生一个新的python进程.有没有一种方法可以在一个控制台中连续运行?还是像Matlab一样?

Also every time I run a code file, a new python process is spawned. Is there a way to run consecutive runs in just one console? Again like Matlab?

这听起来对我来说真的很重要,也很琐碎.我是否在这里缺少一些无法找到解决方案的重要东西?

This sounds really essential and trivial to me. Am I missing something big here that I can't find a solution for this?

推荐答案

我是扩展程序的作者. 有两种选择:

I'm the author of the extension. There are two options:

  1. 使用集成的终端窗口(我想您已经知道了)
    启动终端窗口,然后输入python.
    在REPL中执行的每个语句都在同一会话中.

  1. Use the integrated terminal window (I guess you already knew this)
    Launch the terminal window and type in python.
    Every statement executed in the REPL is within the same session.

下一版本将添加对Jupyter的支持.
请在这里查看一些即将出现的示例:

Next version will add support for Jupyter.
Please have a look here for some samples of what is yet to come:

  • #303
  • Screen samples and more

这篇关于Visual Studio代码交互式Python控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆