Difference between Python 2 and Python 3

来源:互联网 发布:js settimeout原理 编辑:程序博客网 时间:2024/06/06 00:56

For the beginner of Python, we may feel confused when use python. Because the argument for python 2 cannot use in python 3. This may lead to mistake when we submite out code to codeforces or other site. So, I will list some difference between them:


The first one is input() vs raw_input()

When we get used to

n = int(raw_input())

we may feel unsafe to use the argument like that below:
n = input()

no more raw_input() in python 3.


the second one is range vs xrange

I think xrange is more efficient. Python 3 deprecated xrange.


print n vs print (n)

() is a must in python 3


no more  __metaclass__ = type in python 3


more will come! hope to help you geeks!

0 0
原创粉丝点击