Python is a popular programming language used by a lot of people from different professions. Python is a scripting language supported by different platforms and operating systems like Windows, Linux, MacOS, BSD, etc. Developing and running python can be done in different ways but in a practical way, we generally need some editor. Python Idle is a simple editor that provides basic features of advanced Integrated Development Environments.
Python是一种流行的编程语言,许多不同专业的人都在使用它。 Python是受不同平台和操作系统(例如Windows,Linux,MacOS,BSD等)支持的脚本语言。开发和运行python的方法可以不同,但实际上,我们通常需要一些编辑器。 Python Idle是一个简单的编辑器,提供高级集成开发环境的基本功能。
对于Windows安装 (Install For Windows)
In Windows Idle is provided with the Python libraries and executable. In this tutorial, we will download Python 3.6 with Idle from the following link. We prefer 64 bit Python.
在Windows中,Idle随Python库和可执行文件一起提供。 在本教程中,我们将从下面的链接下载带空闲的Python 3.6。 我们更喜欢64位Python。
https://www.python.org/ftp/python/3.6.3/python-3.6.3-amd64.exe
https://www.python.org/ftp/python/3.6.3/python-3.6.3-amd64.exe
![Install For Windows](https://i-blog.csdnimg.cn/blog_migrate/ddcc03f41a203d905669fabbd3a5ed50.png)
为Ubuntu,Debian,Mint,Kali安装(Install For Ubuntu, Debian, Mint, Kali)
We can install idle
with different ways but the easiest and reliable way is using package manager named apt
.
我们可以通过不同的方式安装idle
,但是最简单可靠的方法是使用名为apt
软件包管理器。
$ sudo apt install idle
![Install For Ubuntu, Debian, Mint, Kali](https://i-blog.csdnimg.cn/blog_migrate/ce79613ad6dde9ba942049deee87655d.png)
为Fedora,CentOS,RHEL安装(Install For Fedora, CentOS, RHEL)
We can install Python Idle in the Fedora, CentOS and RHEL distributions like below.
我们可以在下面的Fedora,CentOS和RHEL发行版中安装Python Idle。
$ sudo yum install idle
交互式Python Shell (Interactive Python Shell)
The idle main window is an interactive Python shell. We can use this shell for simple and fast scripting. This console provides the following features.
空闲的主窗口是一个交互式Python shell。 我们可以使用此shell进行简单快速的脚本编写。 此控制台提供以下功能。
- Creating and saving script files 创建和保存脚本文件
- Editing script files编辑脚本文件
- Creating new Python shells创建新的Python Shell
- Debugging Python scripts 调试Python脚本
![Interactive Python Shell](https://i-blog.csdnimg.cn/blog_migrate/145cd7952a0ba7489909821a1b7b8423.png)
建立新档案 (Create New File)
Idle opens Python shell by default. The shell can be used simple scripts or test but for bigger projects, we should create a python script file and save our code to this file. We can create a script file from File->New File menu like below. After completing coding we should save the file with a related name.
空闲默认情况下会打开Python Shell。 可以使用简单的脚本或测试外壳,但是对于较大的项目,我们应该创建一个python脚本文件并将代码保存到该文件中。 我们可以从File-> New File菜单创建脚本文件,如下所示。 完成编码后,我们应该使用相关名称保存文件。
![Create New File](https://i-blog.csdnimg.cn/blog_migrate/9446bc3d71f0b0564a0b95b3e5bf8f4c.png)
运行脚本文件(Run Script File)
We will use the following code to run. We will use F5
in order to run the following code. An alternative way to run is by clicking Run
->Run Module
from the menu.
我们将使用以下代码来运行。 我们将使用F5
来运行以下代码。 另一种运行方式是从菜单中单击Run
-> Run Module
。
age = input("Say your age:")
print("You are "+age+" years old")
This will open Idle shell window and run our script in the Python shell as we can see below.
这将打开Idle shell窗口,并在Python shell中运行脚本,如下所示。
![Run Script File](https://i-blog.csdnimg.cn/blog_migrate/950847993f91ca0329491b215ec4ec1a.png)
翻译自: https://www.poftut.com/download-install-and-use-python-idle-editor/