【发布时间】:2013-05-05 00:38:33
【问题描述】:
我有一个浮点数列表,每个数字都有 3 个小数(例如 474.259)。如果我像这样验证列表中的数字:
if 474.259 in list_sample:
print "something!"
然后显示消息,但是如果我从另一个列表中获取数字并将其四舍五入:
number = other_list[10]
number = round(number, 3)
if number == 474.259:
print "the numbers are same!"
if number in list_sample:
print "something!"
第二条消息没有显示。
【问题讨论】: