简体   繁体   English

PyCharm 中 Python 控制台和终端之间的区别

[英]Difference between Python console and Terminal in PyCharm

I am a beginner in Python.我是 Python 的初学者。 I started using PyCharm recently but I don't know what's the difference between Terminal and console.我最近开始使用 PyCharm 但我不知道终端和控制台有什么区别。 Some of the commands in Terminal do not work in console.终端中的某些命令在控制台中不起作用。

Thank you谢谢

Before we can talk about the differences, we need to talk about what the two are in practice.在我们谈论差异之前,我们需要先谈谈两者在实践中的区别。 The Terminal, essentially replaces your command-prompt/power-shell on windows and the terminal app on Mac, giving you a way to access them without leaving PyCharm .终端基本上取代了 windows 上的命令提示符/电源外壳和 Mac 上的终端应用程序,让您无需离开 PyCharm即可访问它们。

在此处输入图像描述

The PyCharm console on the other hand, is a more advanced version of the "Python Console", which allows you to run bits of Python.另一方面,PyCharm 控制台是“Python 控制台”的更高级版本,它允许您运行 Python 的位。 It is also called the Python REPL or R ead E val P rint L oop它也被称为 Python REPL 或R ead E val P rint L oop

在此处输入图像描述

You can invoke the Python Console from the terminal as well.您也可以从终端调用 Python 控制台。

The terminal is your bash or windows command line where you can execute shell or windows "cmd.exe" commands like: The terminal is your bash or windows command line where you can execute shell or windows "cmd.exe" commands like:

$ cd /
$ ls
$ echo "Hello world!!!"

The Python console is your interactive console where you can execute python code Python 控制台是您的交互式控制台,您可以在其中执行python 代码

>>> x, y = 1, 2
>>> x
1
>>> y
2
>>> x + y
3
>>> print("Hello world!!!")
Hello world!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM