python2和3的主要区别

1. python3中print成为了函数

2. python3不再有unicode对象,默认的str就是unicode

3. python3除号返回浮点数

4. 增加类型注解协助ide进行类型提示和检查

5. super直接调用父类函数(super().func())了,对python2的super进行了优化(python2需要传入当前类和self,super(class,self).func())

6. 增加了高级解包操作;  a,b,*c = range(10)

7. 原生协程支持异步编程

8. 内置库的修改,例如: urllib等等

9. range的懒加载,返回的是range类型的可迭代对象,迭代可以显示

10. 新增futures等内置库

等等

常用库: os sys   smtp request  selenium time glob  shutil  collections  logging  re等等



原文地址:https://www.cnblogs.com/wenshu/p/12301864.html