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中只有新式类

 

posted on 2018-08-02 20:26  哟,写bug呢??  阅读(316)  评论(0编辑  收藏  举报

导航