python - Pycharm 中的命令窗口

标签 python console pycharm

Pycharm 中是否有一个界面,我们可以简单地输入一些命令并运行它? 类似于在 Matlab 中,我们可以输入“a = 1; b = 2; c = a+b”然后我们得到 ans=3。

谢谢 PS:我们知道我们可以在 Pycharm 中创建一个 python 文件并运行它,例如,“a = 1; b = 2; c = a+b; print(c)”,但它不如命令窗口方便。

最佳答案

来自文档的简短回答:

To launch an interactive console On the main menu, choose Tools | Run Python console.

描述:

REPL console

PyCharm also helps those who love the full control of an interactive console: on the Tools menu, you can find commands that launch the interactive Python or Django consoles. Here you can type commands and execute them immediately. Moreover, PyCharm's interactive consoles feature syntax highlighting, code completion, and allow viewing the history of commands (Ctrl+Alt+E or Up/Down arrows while in the editor).

PyCharm also makes it possible to run in console source code from the editor — just make your selection, and then press Shift+Alt+E (Execute selection in console on the context menu of the selection).

独立于 Pycharm,您还可以通过键入

在终端(或 Windows 上的 cmd shell)中访问 REPL
python

在提示符下。

关于python - Pycharm 中的命令窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37017245/

相关文章:

python - 没有名为 'azure.eventhub' 的模块; 'azure' 不是一个包

Python:OSError:[Errno 2] subprocess.Popen 上没有这样的文件或目录

python - 如何在 Python 中针对 DTD 文件验证 xml

python - 如何修复 python 3 中超出预期的大小

python - python中可以直接传字典实例化另一个对象吗

macos - 在 Mac OS X 上使用 Symfony 中的应用程序/控制台

c++ - 什么会导致 cout << variable << "\t";当输出超过终端宽度时打印空格而不是值?

Python:在列表列表中找到最左边的非零值

c# - 用引号解析命令行参数

python - 如何在Pycharm中将现有目录转换为python包