通过Excel 做配置文件调整参数,转换为实时参数:
naclo_reduce_ratio = pd.read_excel('./config/naclo_reduce_ratio.xlsx', header=0) # col_name = ['Time', 'r1', 'r2']
time_lst = []
for i, row in naclo_reduce_ratio.iterrows():
now_time_lst = str(row['Time']).split('.')
time_key = datetime(year=now_temp.year, month=now_temp.month, day=now_temp.day, hour=int(now_time_lst[0]),
minute=int(eval('0.' + now_time_lst[1])*60))
r1 = row['r1']
r2 = row['r2']
time_lst.append([time_key, r1, r2])
# print(f'查看使用的time_lst:{time_lst}')
for index, time in enumerate(time_lst[:-1]):
if time_lst[index][0] <= now_temp < time_lst[index + 1][0]:
r_1 = time_lst[index][1]
r_2 = time_lst[index][2]
print(f'查看实时时间:{now_temp}, t1:{time_lst[index][0]},t2:{time_lst[index + 1][0]}, r1:{r_1}, r2: {r_2}')
配置文件,注意导入时文件名称: