# python2 >>> a = range(5) >>> a [0, 1, 2, 3, 4] >>> b = xrange(5) >>> b xrange(5)
但在python3中,Python3中只有range()。
# python3 >>> a = range(5) >>> a range(0, 5) >>> b = xrange(5) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'xrange' is not