python基础01——python2X和python3X的区别

目前python分了python2和python3版本,一些用法不太一样,总结如下:

区别1:语言特点

python2x:源码重复,不规范

python3x:整合源码,更清晰简单优美

 区别2:编码

python2x: 默认的编码是ascii。在windows上运行时,中文总是会报错,解决方式:在文件的开头加上#-*- encoding:utf-8 -*-

python3x: 默认的编码是utf-8

区别3:数据类型

python2x : 有long int 类型

python3x:无long int 类型

区别4:print

python2x : print 2种写法:print "abc" 或者print ("abc")

python3x  : print 只能用print ("abc")

区别5:从控制台读入数据input

python2x : raw_input() 只能输入字符串,input()只能输入数字类型

python3x :没有raw_input(), 只有input()


还有其他的区别,待更新。。。。。。。

原文地址:https://www.cnblogs.com/yimiaoyikan/p/8707988.html