
然 后, 选 择“ 文 件 -> 保 存”。 当 提 示 输 入 文 件 名, 输 入 hello.py,并把文件保存到桌面,然后选择“运行 -> 运行模块”。不出问题的话,你保存的程序就可以运行了,如图所示。
- print("Hello World")

现在,如果你关闭 Shell 程序窗口,但留着 hello.py 窗口,然后选择“运行 -> 运行模块”,那么 PythonShell 程序会再次出现,并且你的程序会再次运行。(要想不运行程序就重新打开 PythonShell 程序,选择“运行 ->PythonShell 程序”。)在运行代码后,你会在桌面上发现一个新的标有 hello.py 的图标。如果你双击这个图标,会短暂地出现一个黑色窗口然后马上消失。到底发生了什么?你看到的是 Python 命令行控制台(类似 于 Shell 程 序) 启 动, 打 印 出“HelloWorld”,然后退出。如果你有超级英雄一样快速的视觉的话,在窗口关闭前你会看到如图所示的内容。

除了用菜单之外,你还可以用快捷键来创建新的 Shell 程序窗口,保存文件和运行程序。1. 在 Windows 和 Ubuntu 上用 Ctrl-N 来创建一个新的 Shell 程序窗口,在编辑完毕后用 Ctrl-S 来保存文件,按 F5 来运行程序。2. 在苹果 OS X 上用

