为什么这不起作用?
reflace=0
input = "55,1,1,1".split(",")
# Now find the first field from comma
input[reflace] = round( float( input[reflace] ) , 2) + 0.01
ranges = [(-1,1)]
if any(lower <= input[reflace] <= upper for (lower, upper) in ranges):
print "+ " + input
不打印
答案 0 :(得分:1)
将字符串的名称从input
更改为其他名称。我正在使用inputData
。
reflace=0
inputData = "55,1,1,1".split(",")
# Now find the first field from comma
inputData[reflace] = round( float( inputData[reflace] ) , 2) + 0.01
print inputData[reflace] ### Will print 55.01
ranges = [(-1,1)]
if any(lower <= inputData[reflace] <= upper for (lower, upper) in ranges):
print "+ " + inputData
所以,你要检查55.01是否在-1,1的范围内。这不是真的。这就是为什么没有任何东西被打印出来。