Listing 6. The range and xrange methods.
清单6.range和xrange方法。
For example, you can set the xrange also: plot [-pi: PI] sin (x).
例如,还可以设置xrange:plot [-pi:pi]sin (x)。
This same concern got xrange() and xreadlines() added to Python in earlier versions.
同样是这个问题,使得 Python较早的版本中添加了xrange()和xreadlines() 。
The Python for loop can mimic this behavior by using the built-in range and xrange methods.
Pythonfor循环可以通过使用内置的range和xrange方法来模拟该行为。
As always, [" 31-may-04 ":" 11-jun-04 "] sets up the xrange explicitly, but is not strictly necessary.
象往常一样,[“ 31 - May -04 ”: “ 11 - Jun - 04 ”]显式设置了xrange,但不是完全必要的。
Setting the y-range is similar (use yrange instead of xrange in the command), but I don't talk about it.
设置y 范围与 x 范围相似(在命令中使用yrange,而不是xrange ),但我将不再讨论。
The xrange method behaves much like the range method in that it creates a list of integers (and takes the same arguments).
由于 xrange方法也创建整数 list(其使用相同参数),所以它与 range 方法非常相似。
For example, in Listing 6, attempting to print out the newly created xrange didn't show anything other than the name of the xrange.
例如,在清单6中,尝试打印出新创建的xrange时除了xrange的名称,不会显示任何数据。
Functions like xrange are a bit "special" in being generator-like, but neither quite a real iterator (no.next method), nor a realized list like range returns.
xrange这样的函数与生成器类似的方面有些“特殊”,它们既不是真正的迭代器(没有.next方法),也不是实际的列表(比如range返回的列表)。
The xrange method is preferred when you need to iterate over a large number of integers because it won't create the full list, which could consume a large quantity of your computer's memory.
当需要迭代大量整数时,xrange方法更适用,因为它不会创建极大的list,那样会消耗大量计算机内存。
The xrange method is preferred when you need to iterate over a large number of integers because it won't create the full list, which could consume a large quantity of your computer's memory.
当需要迭代大量整数时,xrange方法更适用,因为它不会创建极大的list,那样会消耗大量计算机内存。
应用推荐