-
207 votesanswersviews
NameError:全局名称'xrange'未在Python 3中定义
我在运行python程序时遇到错误: Traceback (most recent call last): File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 110, in <module> File "C:\Program File... -
225 votesanswersviews
为什么Python3中没有xrange函数?
最近我开始使用Python3,它缺乏xrange的伤害 . 简单的例子: 1) Python2: from time import time as t def count(): st = t() [x for x in xrange(10000000) if x%4 == 0] et = t() print et-st count() 2) Python3: from tim... -
635 votesanswersviews
Python 2.X中range和xrange函数有什么区别?
显然xrange更快但我不知道为什么它更快(除了轶事到目前为止没有证据表明它更快)或者除此之外还有什么不同 for i in range(0, 20): for i in xrange(0, 20):