Python3 和 Python2 的区别?

2023-05-09  本文已影响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。

上一篇 下一篇

猜你喜欢

热点阅读