Day1_Python基础_3.Python2 or 3 ?

三、Python 2 or 3?

In summary : Python 2.x is legacy, Python 3.x is the present and future of the language

Python 3.0 was released in 2008. The final 2.x version 2.7 release came out in mid-2010, with a statement of

extended support for this end-of-life release. The 2.x branch will see no new major releases after that. 3.x is

under active development and has already seen over five years of stable releases, including version 3.3 in 2012,

3.4 in 2014, and 3.5 in 2015. This means that all recent standard library improvements, for example, are only

available by default in Python 3.x.

Guido van Rossum (the original creator of the Python language) decided to clean up Python 2.x properly, with less regard for backwards compatibility than is the case for new releases in the 2.x range. The most drastic improvement is the better Unicode support (with all text strings being Unicode by default) as well as saner bytes/Unicode separation.

Besides, several aspects of the core language (such as print and exec being statements, integers using floor division) have been adjusted to be easier for newcomers to learn and to be more consistent with the rest of the language, and old cruft has been removed (for example, all classes are now new-style, "range()" returns a memory efficient iterable, not a list as in 2.x).

py2与3的详细区别

PRINT IS A FUNCTION

The statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old statement (PEP 3105). Examples:

+

You can also customize the separator between items, e.g.:


1

print("There are <"2**32"> possibilities!", sep="")

ALL IS UNICODE NOW

从此不再为讨厌的字符编码而烦恼

还可以这样玩: (A,*REST,B)=RANGE(5)


1

2

3

4

<strong>>>> a,*rest,b = range(5)

>>> a,rest,b

(0, [123], 4)

</strong>

  

某些库改名了

Old Name

New Name

_winreg

winreg

ConfigParser

configparser

copy_reg

copyreg

Queue

queue

SocketServer

socketserver

markupbase

_markupbase

repr

reprlib

test.test_support

test.support

  

还有谁不支持PYTHON3?

One popular module that don‘t yet support Python 3 is Twisted (for networking and other applications). Most

actively maintained libraries have people working on 3.x support. For some libraries, it‘s more of a priority than

others: Twisted, for example, is mostly focused on production servers, where supporting older versions of

Python is important, let alone supporting a new version that includes major changes to the language. (Twisted is

a prime example of a major package where porting to 3.x is far from trivial

时间: 2024-08-30 05:02:14

Day1_Python基础_3.Python2 or 3 ?的相关文章

零基础学python-2.17 文件、open()、file()

今天我们来说说文件,以及跟文件有关的内建函数open和file 首先我们在python的根目录下建一个名为"123"的txt文本文件 文件里面我们输入一些文本 我们把新建文件与源代码都放到python根目录下面 下面我们来看看代码: handler=open("123.txt")#由于把文件跟源代码建立在python的根目录, #所以这里的路径只需打名字即可 for eachLine in handler: print(eachLine,end='') handle

零基础学python-2.7 列表与元组

其实,可以把列表和元组看成普通的数组,但是这个数组可以存储不同的数据类型(对象) 列表和元组的区别   列表 元组 使用的符号 [] () 元素数量 可变 不可变 修改元素 不可以 可以 如果大家有编程基础,列表就像java里面的List,元组就像java里面的数组,不过这个数组是只读的 下面给大家举个例子: 列表可以使用下标来读取或者修改元素 元组只可以通过下标读取元素,不可以修改元素 元组可以像字符串一样使用切片操作符来截取元素,但是有个区别就是,如果下标为负数或者超过元组长度,不显示 这节

零基础学python-2.18 异常

这一节说一下异常except 继续沿用上一节的代码.我有益把文件名称字搞错.然后在结尾部分加上异常捕捉: try: handler=open("12.txt")#在这里我特别将文件的名字搞错 for eachLine in handler: print(eachLine,end='') handler.close() except IOError as e: print(e) 他会出现报错的内容: python本身包括了非常多异常,我们将会后面具体展开 就讲到这里.谢谢大家 -----

零基础学python-2.2 输入 input()

这节课我们来聊一下输入函数input() input()主要是读取标准输入,然后赋值给指定的变量 例如: 上图所示,我们把输入的123赋值给temp这个变量,然后后面通过print打印出来 再回到我们的游戏上面,我们猜数字,必须要输入,所以肯定需要用input函数 所以,我们在代码里面加入输入,然后改进成下面的代码: print("---------欢迎来到猜数字的地方,请开始---------") guess=int(input("*数字区间0-100,请输入你猜的数字:&

零基础学python-2.23 模块

这一节我们来聊聊模块 1.模块:函数.类等组合在一个文件里面 2.导入模块: import xxx 3.调用模块方法 import sys sys.platform 输出:'win32' 详细的展开会在后面的章节. 就说到这里,谢谢大家 ------------------------------------------------------------------ 点击跳转零基础学python-目录 版权声明:本文为博主原创文章,未经博主允许不得转载.

零基础学python-2.24 一些常用函数

今天我举一些常用的函数,让大家了解一下: 函数 作用 dir([obj]) 浏览对象的属性 help([obj]) 显示对象的文档字符串 ini([obj]) 将对象转为整形 len([obj]) 返回对象长度 open([obj]) 打开文件 range(start,stop) 取一定范围的整数 input(str) 输入 str(obj) 将对象转为字符串 type(obj) 返回对象类型 就说到这里,谢谢大家 ----------------------------------------

Day1_Python基础_17.拾遗

一.bytes类型 二.三元运算 result = 值1 if 条件 else 值2 如果条件为真:result = 值1如果条件为假:result = 值2 三.进制 二进制,01 八进制,01234567 十进制,0123456789 十六进制,0123456789ABCDEF  二进制到16进制转换http://jingyan.baidu.com/album/47a29f24292608c0142399cb.html?picindex=1 计算机内存地址和为什么用16进制? 为什么用16进

零基础学python-2.15 回到我们的游戏 加入for以及列表

我们先贴上之前的代码,回顾一下功能 import random secret=random.randint(1,100)#生成随机数 #print (secret) time=6#猜数字的次数 guess=0#输入的数字 minNum=0#最小随机数 maxNum=100#最大随机数 print("---------欢迎来到猜数字的地方,请开始---------") while guess!=secret and time>=0:#条件 guess=int(input("

零基础学python-2.16 列表解析

这一节聊聊强大的列表解析 主要就是在一行里面赋值给列表 下面我们举两个例子: 上面的例子我们引入了range函数,他主要作用是在一定范围里面取整数值 我来解释一下中括号里面的那一句:x**2 for x in range(5) 1.先计算range里面的值 2.通过for,把上面的整数值赋值给x 3.再计算x**2 4.最后就是逐一放到square这个列表里面去 除了上面的这些,我们还可以控制range取的值 例如: 从上图的if我们可以看见,我们把x限定在可以整除2这些数上面. 这节就说到这里