嗨,這是非常混亂...發現價值,在這事件發生的Python
我試圖找到最小的數組:
for xpre in range(100): #used pre because I am using vapor pressures with some x molarity
xvalue=xarray[xpre]
for ppre in range(100): #same as xpre but vapor pressures for pure water, p
pvalue=parray[p]
d=math.fabs(xvalue-pvalue) #d represents the difference(due to vapor pressure lowering, a phenomenon in chemistry)
darray.append(d) #darray stores the differences
mini=min(darray) #mini is the minimum value in darray
darr=[] #this is to make way for a new set of floats
所有陣列(xarr ,parr,darr)已經定義,什麼不是。他們有100浮動每個
所以我的問題是我將如何找到pvap和xvap @其中min(darr)被找到?
編輯 已經改變了一些變量名,並添加變量描述,對不起你們
您確實不需要使用索引。 – habnabit 2010-08-17 06:00:57
作者詢問如何找到pvap和xvap的最小值(及其對應的'darr'索引)。實際上,您需要使用這些列表中的索引來再次找到它們。 :) – Andrew 2010-08-17 06:08:38
感謝您的解釋,幫了很多:) 但'minindex = darr.index(微型)'返回一個錯誤;顯然''字典'對象沒有'index'的屬性 – pjehyun 2010-08-17 06:45:06