python2与python3的区别

默认解释器编码:py2,ascii;python3,utf-8;
字符串和字节相关:
py2:  unicode     str(utf-8,gbk)  
py3:  str       bytes(utf-8,gbk)
经典类和新式类:
py2,经典类和新式类 py3,新式类(默认继承object)
字典的keys和values:
py2:.keys() 获取到的是列表 py3:迭代器
yield from:
py2:没有
py3:有
线程池和进程池:
py2:有进程池/没有线程池
from multiprocessing import Pool
py3:有进程池/有线程池
from concurrent.futures.thread import ThreadPoolExecutor
from concurrent.futures.process import ProcessPoolExecutor
- keys
- py2:列表
- py3:迭代器,可以循环单不可以索引
- values
- py2:列表
- py3:迭代器,可以循环单不可以索引
- values
- py2:列表
- py3:迭代器,可以循环单不可以索引
- map/filter
- py2:返回列表
- py3:返回迭代器,可以循环单不可以索引

原文地址:https://www.cnblogs.com/blackball9/p/10985275.html