PyCharm running Python file always opens a new console(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 文件总是打开一个新的控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PyCharm 运行 Python 文件总是打开一个新的控制台
基础教程推荐
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
