0
import xlrd
file_path = r"C:\Users\Allen\Desktop\数据曲线.xlsx"
table = xlrd.open_workbook(file_path).sheet_by_index(2)
data_current = table.col_values(4)[1:]
data_time = table.col_values(2)[1:]
time_start = []
for i in data_current:
index = data_current.index(i)
if float(i) < 0.1 and float(data_current[index+1]) > 1:
print('come on!')
else:
print('a')
マイ入力:if文の浮動小数点値のテストが常にfalseになるのはなぜですか?
data_current = ['0.0', '0.0', '1.44']
これは単なる一例であるが、実際のデータは同じ構造に従います。
出力が常にa
で、決してcome on!
にならないのはなぜですか?常に0
になるだろう'0.0'
index
ためのよう
ありがとうございます! – cwl