PyCharm 运行 Python 文件总是打开一个新的控制台 [英] PyCharm running Python file always opens a new console

查看:36
本文介绍了PyCharm 运行 Python 文件总是打开一个新的控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最初开始在 Spyder 中学习 Python,但最近决定切换到 PyCharm,因此我正在以类似 Spyder 的心态学习 PyCharm.

I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality.

我有兴趣在 Python 控制台中运行一个文件,但是每次我重新运行这个文件时,它都会在新打开的 Python 控制台下运行.这可能会在一段时间后变得烦人,因为将打开多个 Python 控制台,它们基本上都做同样的事情,但略有不同.

I'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations.

我希望只有一个 Python 控制台并在该控制台中运行整个文件.有人知道如何改变吗?也许我使用的心态不是很 PyCharmic?

I would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?

推荐答案

在 PyCharm 2018.2+ 中有一个特定的选项:Settings |构建、执行、部署 |控制台 |将现有控制台用于使用 Python 控制台运行".

There is a specific option in PyCharm 2018.2+: Settings | Build, Execution, Deployment | Console | Use existing console for "Run with Python console".

使用 Python 控制台运行 是您在运行配置中启用的选项.如果您在脚本执行后不需要 Python 控制台,请禁用它:

Run with Python console is an option you have enabled in the Run Configuration. Disable it if you don't need a Python console after a script execution:

这篇关于PyCharm 运行 Python 文件总是打开一个新的控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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