Python2与Python3的主要区别
区别一:print语法使用
python2.7print语法使用>>>print"HelloPython"
Python3.7print语法使用>>>print("HelloPython")
区别二:raw_input()和input()
Python2.7raw_input()input()都存在可使用raw_input()接收字符串stringinput()接收数字int/flot.
Python3.7raw_input()不存在仅存在input()两者合并接收任意格式返回string
区别三:函数cmp()
python2.7cmp(x,y)函数用于比较2个对象,如果x
python3.7cmp()已经不存在了,如果你需要实现比较功能,需要引入operator模块,适合任何对象
以上内容为大家介绍了Python2与Python3的主要区别,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
Python 枚举
1.枚举的定义首先,定义枚举要导入enum模块。枚举定义用class关键字,继承Enum类。用于定义枚举的class和定义类的class是有区别【下一篇博文继...详情>>
2023-11-06 13:46:00
Python多核编程mpi4py实践
一、概述CPU从三十多年前的8086,到十年前的奔腾,再到当下的多核i7。一开始,以单核cpu的主频为目标,架构的改良和集成电路工艺的进步使得cpu...详情>>
2023-11-06 09:21:36
python之增量式爬虫是什么?
引言:当我们在浏览相关网页的时候会发现,某些网站定时会在原有网页数据的基础上更新一批数据,例如某电影网站会实时更新一批最近热门的电影。...详情>>
2023-11-06 07:21:56
Python之父Guido谈Python的未来
Python在移动计算领域的应用Guido:移动对Python来说仍是一个很难啃下来的平台,但是并没有浏览器平台的难度大,因为Python实际上是可以运行在...详情>>
2023-11-06 02:14:20