Python发展史+python 2 or 3区别

网友投稿 992 2022-10-12

Python发展史+python 2 or 3区别

Python发展史+python 2 or 3区别

Python发展史

1989年,为了打发圣诞节假期,Guido开始写Python语言的编译器。Python这个名字,来自Guido所挚爱的电视剧Monty Python’s Flying Circus。他希望这个新的叫做Python的语言,能符合他的理想:创造一种C和shell之间,功能全面,易学易用,可拓展的语言。1991年,第一个Python编译器诞生。它是用C语言实现的,并能够调用C语言的库文件。从一出生,Python已经具有了:类,函数,异常处理,包含表和词典在内的核心数据类型,以及模块为基础的拓展系统。Granddaddy of Python web frameworks, Zope 1 was released in 1999Python 1.0 - January 1994 增加了​​lambda​​​,​​map​​​,​​filter​​​ and​​reduce​​.Python 2.0 - October 16, 2000,加入了内存回收机制,构成了现在Python语言框架的基础Python 2.4 - November 30, 2004, 同年目前最流行的WEB框架Django 诞生Python 2.5 - September 19, 2006Python 2.6 - October 1, 2008Python 2.7 - July 3, 2010In November 2014, it was announced that Python 2.7 would be supported until 2020, and reaffirmed that there would be no 2.8 release as users were expected to move to Python 3.4+ as soon as possiblePython 3.0 - December 3, 2008Python 3.1 - June 27, 2009Python 3.2 - February 20, 2011Python 3.3 - September 29, 2012Python 3.4 - March 16, 2014Python 3.5 - September 13, 2015

Python 2 or 3区别

有道翻译:总之:Python 2.x是遗产,python3。x是语言的现在和未来

对这个生命结束版本的扩展支持的2.在此之后,x分支将不会看到新的主要版本3.x是在积极的开发中,已经经历了五年多的稳定发布,包括2012年的3.3版,3.4 2014年,3.5 2015年。这意味着,例如,所有最近的标准库改进都只是Python 3.x中默认可用。

Guido van Rossum (Python语言的最初创造者)决定清理Python 2。正确地说,与2中的新版本相比,x更少考虑向后兼容性。x范围。最显著的改进是更好的Unicode支持(默认情况下所有文本字符串都是Unicode)以及更合理的字节/Unicode分离。

除此之外,几个方面的核心语言(如打印和执行语句,整数使用地板部门)已经调整为新手更容易学习和更符合其他的语言,已被删除老的繁琐(例如,所有类现在新型“范围()返回一个内存高效iterable,不像在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:

该语句已被print()函数替换,并使用关键字参数替换旧语句(PEP 3105)的大部分特殊语法。例子:

1

2

3

4

5

6

7


​Old: ​​​​print​​​ ​​"The answer is"​​​​, ​​​​2​​​​*​​​​2​​​ ​​New: ​​​​print​​​​(​​​​"The answer is"​​​​, ​​​​2​​​​*​​​​2​​​​)​

​Old: ​​​​print​​​ ​​x, ​​​​# Trailing comma suppresses newline New: print(x, end=" ") # Appends a space instead of a newline​

​Old: ​​​​print​​​ ​​# Prints a newline​

​New: ​​​​print​​​​() ​​​​# You must call the function!​

​Old: ​​​​print​​​ ​​>>sys.stderr, ​​​​"fatal error"​​​ ​​New: ​​​​print​​​​(​​​​"fatal error"​​​​, ​​​​file​​​​=​​​​sys.stderr)​

​Old: ​​​​print​​​ ​​(x, y) ​​​​# prints repr((x, y))​

​New: ​​​​print​​​​((x, y)) ​​​​# Not the same as print(x, y)!​


You can also customize the separator between items, e.g.: 你也可以自定义项目之间的分隔符,例如:

1


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


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

1

2

3

4


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

​>>> a,rest,b​

​(​​​​0​​​​, [​​​​1​​​​, ​​​​2​​​​, ​​​​3​​​​], ​​​​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?

目前还不支持Python 3的一个流行模块是Twisted(用于网络和其他应用程序)。大多数

积极维护的库让人们致力于3。x的支持。对于一些库来说,它比

其他:例如,Twisted主要专注于生产服务器,支持旧版本的

Python很重要,更不用说支持对该语言进行重大更改的新版本了。(扭曲

一个主要包的主要示例,其中移植到3。x绝不是平凡的

先说python2

再说python3

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:开发小程序需要(开发小程序需要申请专利吗)
下一篇:微信小程序实现--列表的上拉刷新和上拉加载(微信小程序上拉加载)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~