python2和python3的区别

1、print

python2中print函数不需要带括号

print 'test'

 pytho3中print函数必须带括号

print("test")

 2、编码格式

python2中的默认编码是:ASCII

python3中的默认编码是:utf-8

3、除法运算

Python2

print 1/2   #0
print 1.0/2.0   #0.5

python3

print(1/2)#0.5

4、不等于

python 2中不等于有两种表达方式:<>和!=

python3中只保留了一种:!=

 5、新式类经典类

python2中新式类经典类并存,python3中只有新式类

原文地址:https://www.cnblogs.com/linshuhui/p/9409660.html