Python 教程
1. Python3 教程 2. Python3 解释器 3. Python3 注释 4. Python3 数字(Number) 5. Python3 字符串 6. Python3 列表 7. Python3 编程第一步 8. Python3 条件控制 9. Python3 循环语句 10. Python3 函数 11. Python3 数据结构 12. Python3 模块 13. Python3 输入和输出 14. Python3 错误和异常 15. Python3 面向对象 16. Python3 标准库概览 17. Python3 实例 18. Python3 正则表达式 19. Python3 CGI编程 20. Python3 MySQL 数据库连接 – PyMySQL 驱动 21. Python3 网络编程 22. Python3 SMTP发送邮件 23. Python3 多线程 24. Python3 XML 解析 25. Python3 JSON 数据解析 26. Python3 日期和时间 27. Python3 内置函数 28. Python MongoDB 29. Python uWSGI 安装配置

Python3 教程

Python 3 教程

Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。

Python 介绍及安装教程我们在Python 2.X 版本的教程中已有介绍,这里就不再赘述。

你也可以点击 Python2.x与3​​.x版本区别 来查看两者的不同。

本教程主要针对 Python 3.x 版本的学习,如果你使用的是 Python 2.x 版本请移步至 Python 2.X 版本的教程

官方宣布,2020 年 1 月 1 日, 停止 Python 2 的更新。


查看 Python 版本

我们可以在命令窗口(Windows 使用 win+R 调出 cmd 运行框)使用以下命令查看我们使用的 Python 版本:


python -V

以上命令执行结果如下:


Python 3.3.2

你也可以进入Python的交互式编程模式,查看版本:


Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32

Type "copyright", "credits" or "license()" for more information.

>>> 


第一个Python3.x程序

对于大多数程序语言,第一个入门编程代码便是"Hello World!",以下代码为使用Python输出"Hello World!":

实例(Python 3.0+)

#!/usr/bin/python3 print("Hello, World!")

运行实例 »

你可以将以上代码保存在 hello.py 文件中并使用 python 命令执行该脚本文件。


$ python3 hello.py

以上命令输出结果为:


Hello, World!


相关内容:

Python 3.6.3 中文手册

Python 2.X 版本的教程