1.xrangepython
python2.x中,好比使用rang(100),會給分配100的內存保存100個數(執行效率和內存)python3.x
python3.x中,使用xrange,空間複雜度是o(1),要一個數給一個數。spa
2.printcode
python2.x中,print不用加括號blog
python3.x中,print要加括號內存
3.異常io
python2.x中class
a=10 b=0 try: c=a/b print c except ZeroDivisionError,e: print e.message print "done"
python3.x中效率
a=10 b=0 try: c=a/b print(c) except ZeroDivisionError as e: print(e.message) print("done")