我在python上运行以下代码来打印nos。在为偶数浮动号:在Python中获取MemoryError
def float_range(begin,end,step):
i=begin-step
numbers=[]
while i!=end:
i=i+step
numbers.append(i)
return numbers #returning the list
a=2
b=4
c=.1
for j in float_range(a,b,c): #calling function
print j
和它给以下错误
Traceback (most recent call last):
File "C:\Users\b53659\Desktop\My python\float_range.py", line 13, in <module>
for j in float_range(a,b,c):
File "C:\Users\b53659\Desktop\My python\float_range.py", line 7, in float_range
numbers.append(i)
MemoryError.
但在上面的代码中指定,如果我更换范围
a=1
b=1000
c=1
它给正确的输出即没有打印。从1到1000. 为什么会发生?在此先感谢
使用十进制...... – YOU 2015-03-19 10:13:23
http://blog.reverberate.org/2014/09/what-every-computer-programmer -should.html – RvdK 2015-03-19 10:20:25
'而我<结束或使用'epsilon' – 2015-03-19 10:27:44