美文网首页
Python3 和 Python2 的区别?

Python3 和 Python2 的区别?

作者: 阳光小镇少爷 | 来源:发表于2023-05-09 22:53 被阅读0次

1、print 在 Python3 中是函数必须加括号,Python2 中 print 为 class。
2、Python2 中使用 xrange,Python3 使用 range。
3、Python2 中默认的字符串类型默认是 ASCII,Python3 中默认的字符串类型是 Unicode。
4、Python2 中/的结果是整型,Python3 中是浮点类型。
5、Python2 中声明元类:metaclass = MetaClass,Python3 中声明元类:class newclass(metaclass=MetaClass):pass。

相关文章

网友评论

      本文标题:Python3 和 Python2 的区别?

      本文链接:https://www.haomeiwen.com/subject/hfdqsdtx.html