本文概述
- 下载适用于Windows的Python发行版
- 安装发行版
- 将Python添加到系统路径变量
- 你好, 世界
Python旨在成为一种易读的语言, 请参见以下示例:
Python中的For循环
# This is a python commentitems = [1, 2, 3, 4]for i in items:print (i)
Python中的While循环
x=1while x <
= 5:# Convert the number to string using the str methodprint "The number is:" + str(x)x += 1
如你所见, 它被设计为具有整洁的视觉布局, 通常使用英语关键字, 而其他语言使用标点符号。在本文中, 你将学习使用Python for Windows设置极简主义的开发环境。
下载适用于Windows的Python发行版 要下载适用于Windows的Python的最新发行版, 请转到此处主页的” 下载” 页面。
请注意, 在首页中, 你会找到要下载的版本。在python中, 到目前为止有2个版本, 即2x和3x, 但是, 我应该使用Python 2还是Python 3进行开发活动?

文章图片
Python 3.0于2008年发布。最终的2.x版本2.7于2010年中期发布, 并声明了对该生命周期终止版本的扩展支持。在此之后, 2.x分支将没有新的主要发行版。 3.x正在积极开发中, 并且已经有超过五年的稳定版本, 包括2012年的3.3版, 2014年的3.4版和2015年的3.5版。这意味着, 例如, 所有最新的标准库改进仅在默认情况下可用。在Python 3.x中。
特别是, 向新程序员介绍Python的讲师应考虑先教Python 3, 然后再介绍Python 2中的差异(如有必要), 因为Python 3消除了许多怪癖, 这些怪癖可能会使初学者尝试学习Python 2时不必要地绊倒。
在此处详细了解差异。在这种情况下, 我们将下载3x版本。最后, 在下载安装程序后, 转到下一步。
安装发行版 根据你的版本执行安装程序, 设置可能有所不同:

文章图片
请注意, 检查” 将Python 3.5(或任何版本)添加到PATH” 非常重要。这样, 可以在命令提示符(cmd.exe)中使用python关键字, 并且你可以从命令行使用python进行所有操作。
重要提示:如果取消选中此功能, 或者以后如果cmd.exe中没有python变量, 则需要设置系统路径变量。
你显然可以按照自己的方式更改配置(另一个驱动器, 仅选择几个功能, 等等)。
正常继续安装直至结束(安装成功)。

文章图片
将Python添加到系统路径变量 注意:如果你决定使用Python> = 3.4, 则无需遵循此过程, 只需跳到hello world部分即可。
首先打开开始菜单, 然后键入” 环境” , 然后选择名为” 编辑系统环境变量” 的选项。

文章图片
出现” 系统属性” 窗口时, 单击” 环境变量” :

文章图片
打开” 环境变量” 窗口后, 将焦点移到下半部分。你会注意到, 它控制所有” 系统变量” , 而不仅仅是与你的用户相关联的变量。单击” New…” 为Python创建一个新变量。

文章图片
只需输入你的路径名称和下面显示的代码即可。就本示例而言, 我们已经安装了Python 2.7.3, 因此我们将路径称为” Pythonpath” 。
你需要输入的字符串是:” C:\ Python27 \; C:\ Python27 \ Scripts; ” 。请注意, 根据你的版本和安装路径, 需要更改此值。

文章图片
对所有显示的内容按OK, 以接受所有更改并退出” 系统属性” 窗口。
现在, 在cmd.exe中将提供Python路径。
你好, 世界 既然python已经成功安装在我们的系统中, 我们只需要使用它即可。
有两种方法可以在Windows中使用Python实现你的第一个Hello World
1)打开python shell(IDLE)。

文章图片
并在其上执行以下行:
print ("Hello Python World in Our Code World <
3");
恭喜, 你刚刚在python中向世界打了招呼!在IDLE上, 你将能够实时执行python代码, 可以在其上玩更多示例, 例如, 使用math类来确定某物是否不是数字(NaN)。

文章图片
2)使用cmd.exe执行python
打开Windows(cmd.exe)的命令提示符, 然后在其上键入python。
键入python后, 有关python的信息将被侦听, 你将能够从命令行执行python。现在, 在python处于活动状态时键入以下行:
print ("Hello Python World in Our Code World <
3");

文章图片
恭喜, 你刚刚在python中向世界问好。
【如何在Windows上安装python并设置基本的hello world】玩转Python
推荐阅读
- 如何使用CLI检查Ubuntu Server 16.04中的系统规格
- 如何在Ubuntu 16.04中实现软件RAID 1阵列(镜像)
- 如何在Ubuntu 16.04中安装MongoDB
- 如何使用Clappr用J??avaScript创建360 Video Player
- 如何为使用Electron Framework构建的应用程序创建Windows安装程序
- 如何在JavaScript中使用PrognRoll和jQuery在网站中显示滚动进度条
- 如何在HTML5中使用recorder.js记录和导出音频(WAV和MP3)
- 本文教您Win10开机提示“服务器正在运行中”怎样
- 本文教您win10怎样设置文件的默认打开方式