Questions tagged «xrange»



6
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 Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 27, in __init__ File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\class\inventory.py", line 17, in __init__ builtins.NameError: global name 'xrange' is not defined 游戏是从这里开始的。 是什么导致此错误?

6
为什么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 time import time as t def xrange(x): return iter(range(x)) def count(): st = t() [x for x …
273 python  python-3.x  pep  xrange 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.