def fc_range(start, end, step=1.0):
while start < end:
yield start
start +=step
for x in fc_range(0, 1, 0.05):
print x # look the ans
print list(fc_range(0, 1, 0.05)) # compare the ans now
,當我測試:爲什麼'打印'可以提供一個確切的價值,而其他不是?
>>> 0.1 + 0.05
0.15000000000000002
好像是明確的,但爲什麼當我使用print
答案不是0.15000000000000002
?
你是什麼意思「當我使用打印答案不是0.15000000000000002」?是這裏。 – wRAR