刚学了几天Python,想上手写一写计算,在写for循环的时候数组里共有28个元素,但在for循环下打印出来的循环变量却只有6。
以下是部分代码(数组已列出,其他变量都是测量量,可以任取)
t_jh = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]
for j in range(len(t_jh)):
print(j)
BLh_tjh = HCR * (tah - t_jh[j]) / tah *Qcr_2a
BLh_tjhs.append(BLh_tjh)
if t_jh[j] >= 5.5:
if t_jh[j] >= tdh:
Phmin_tjh = Phmin_tdh + (Phmin_tah - Phmin_tdh) / (tah - tdh) * (t_jh[j] - tdh)
Phmin_tjhs.append(Phmin_tjh)
Qhmin_tjh = Qhmin_n85 + (Qh_min - Qhmin_n85) / (7 - (-8.5)) * (t_jh[j] - (-8.5))
Qhmin_tjhs.append(Qhmin_tjh)
XB_tjh = BLh_tjhs[j] / Qhmin_tjhs[j]
XB_tjhs.append(XB_tjh)
PLFB_tjh = 1 - HCD * (1 - XB_tjhs[j])
PLFB_tjhs.append(PLFB_tjh)
PhB_tjh_1 = XB_tjhs[j] * Phmin_tjhs[j] / PLFB_tjhs[j] * n_jh[j]
PhB_tjhs_1.append(PhB_tjh_1)
if tch < t_jh[j] < tdh:
Phm_tch = Phm_n85 + (Phm - Phm_n85) / (7 - (-8.5)) * (tch - (-8.5))
Phm_tjh = Phm_tch + (Phmin_tdh - Phm_tch) / (tdh - tch) * (t_jh[j] - tch)
Phm_tjhs.append(Phm_tjh)
PhB_tjh_2 = Phm_tjhs[j] * n_jh[j]
PhB_tjhs_2.append(PhB_tjh_2)
运行结果及报错内容
我的解答思路和尝试过的方法
目前完全没有头绪,因为之前也是这么写的但是没有出现过类似的问题。
我想要达到的结果
想要了解为什么在这个循环中循环变量会变成0-5,以及如何得到我想要的数组长度的循环变量,谢谢!