- Python2的open方法不支持encoding参数,Python3支持
python2的报错如下:
f1 = open(r'story', mode='r', encoding='utf-8')
TypeError: 'encoding' is an invalid keyword argument for this function
- Python2中无bytes类型,Python3中有bytes类型
# Python2
print(type(b'1'))
<type 'str'>
# Python3
print(type(b'1'))
<class 'bytes'>
- Python3的time模块有perf_counter()方法,Python2没有