Python 3 教程

Python 3 教程 · 2019-02-04 16:27:57
python3

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版本的教程。

查看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!

相关内容:

Python3.6.3 中文手册

点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html

查看所有标签

Python Data Structures and Algorithms

Python Data Structures and Algorithms

Benjamin Baka / Packt Publishing / 2017-5-30 / USD 44.99

Key Features A step by step guide, which will provide you with a thorough discussion on the analysis and design of fundamental Python data structures.Get a better understanding of advanced Python c......一起来看看 《Python Data Structures and Algorithms》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换