我收到TypeError:'float'对象在我的while语句中没有属性' getitem '。在这种情况下,我不确定问题是什么。我在代码中使用sys
s1P = 4.51775*10.0**16.0
ii= 1
while s1P[ii-1] > 0.0
sys.stdout.write('\rstep={0}'.format(ii))
sys.stdout.flush()
Rad = s1r[ii-1]+delrms1[ii-1]*delm
Mas = s1m[ii-1]*[i]
Pres = s1P[ii-1]+delPms1[ii-1]*delm
lPres = np.log10(Pres)
Temp = s1T[ii-1]+delTms1[ii-1]*delm
lTemp = np.log10(Temp)
Lum = s1L[ii-1]+deLms1[ii-1]*delm
Rho = (Pres - 1.0/3.0*a*Temp**4.0)*mu/(NA*k*Temp)
lRho = np.log10(Rho)
lR = np.log10(10.0**lRho/(10.0**Temp/10.0**6)**3.0)
lK = interpolate.bisplev(lTemp,lR,tck)
K = 10.0**lK
T_n = Temp/(10.0**9.0)
epp = 2.4*10.0**4.0*(Rho*X**2.0/T_n**(2.0/3.0))*np.exp(-3.38/T_n**(1.0/3.0))
ecno = 4.4*10.0**25.0*(Rho*X*Z/T_n**(2.0/3.0))*np.exp(-15.228/T_n**(1.0/3.0))
eta = 5.0*10.0**8.0*(Rho**2.0*Y**3.0/T_n**3.0)*np.exp(-4.4/T_n)
ec = epp+ecno+eta
Bt = NA*k*Rhoc*T_n/(Pres*mu)
Gam2 =(32.0-24.0*Bt-3.0*Bt**2.0)/(24.0-18.0*Bt-3.0*Bt**2.0)
drm = 1.0/(4.0*np.pi*Rad**2.0*Rho)
dPm = -G*Mas*1.99*10.0**33.0/(4.0*np.pi*Rad**4.0)
dLm = eg
Term1 = 16.0*np.pi*a*c*G/(3.0*K)
Term2 = (1.0-1.0/Gam2)
Term3 = Temp**4.0*(Mas*1.99*10.0**33.0)/Pres
Tal = Term1+Term2+Term3
CR = Lum/Tal
dTrm = -3.0*s1K*s1L/(64.0*np.pi**2.0*a*c*s1r**4.0*s1T**3.0)
dTcm = -(1.0-1.0/s1gam2)*(G*s1m*1.99*10.0**33.0*s1T/(4.0*np.pi*s1r**4.0*s1P))
dTm = np.where(Lum > Tal, dTcm, dTrm)
sys.stdout.write('\n')
s1m.append(Mas)
s1r.append(Rad)
s1L.append(Lum)
r_c.append(CR)
s1T.append(Temp)
logs1T.append(lTemp)
s1P.append(Pres)
logs1P.append(lPres)
s1rho.append(Rho)
logs1rho.append(lRho)
logs1K.append(lK)
slK.append(K)
s1eg.append(ec)
s1gam2.append(Gam2)
delrms1.append(drm)
delPms1.append(dPm)
delLms1.append(dLm)
delTm1.append(dTm)
ii = ii+1
sys.stdout.write('\n')
s1m=s1m[:-1]
s1r=s1r[:-1]
s1L=s1L[:-1]
r_c=r_c[:-1]
s1T=s1T[:-1]
logs1T=logs1T[:-1]
s1P=s1P[:-1]
logs1P=logs1P[:-1]
s1rho=s1rho[:-1]
logs1rho=logs1K[:-1]
logs1K=logs1K[:-1]
slK=s1K[:-1]
s1eg=s1eg[:-1]
s1gam2=s1gam2[:-1]
delrms1=delrms1[:-1]
delPms1=delPms1[:-1]
delLms1=delLms1[:-1]
delTm1=delTm1[:-1]
附加我的陈述的输出可能仍然是个问题吗?
答案 0 :(得分:2)
如果s1P
应该是列表,那么你需要像
s1P = [4.51775*10.0**16.0]
而不是s1P = 4.51775*10.0**16.0
,这将使它成为一个数字。