
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
1.4 动动手——编写和运行一个Hello World程序
在Python开发环境搭建完成后,我们动手编写并运行Hello World程序来测试一下Python开发环境。
编写和运行Python程序主要有两种方式:
1 交互方式;
2 文件方式。

1.4.1 交互方式
Python安装包提供了交互式运行工具——Python Shell,在安装好Python后,我们就可以单击Windows“开始”菜单打开Python 3.x了。


我们在IDLE中编写如下Hello World代码,然后敲回车键运行。

1.4.2 文件方式
通过文件方式编写和运行Python程序时,首先需要编写Python代码,然后使用Python指令运行Python代码文件。
编写Python代码时,既可以使用任意一种文本编辑工具,也可以使用专业的IDE(Integrated Development Environments,集成开发环境)工具。


在代码编写完成后,就可以运行代码了。在Windows下启动命令提示符,并输入Python hello.py指令。



