2017-08-15 157 views
0

下面是代碼的一部分,其中數據從excel文件中讀取並被傳輸到psspy函數中。我收到有關_i_f不是變量的錯誤。但我通過在PSSE上運行ibdev來收到此代碼。有什麼辦法可以改變這個,這樣錯誤就被消除了。我嘗試使用API​​的默認變量,但它並沒有工作。另外對於數組中的第三個元素,我試圖將一個變量放入一個字符串中,以便它可以在我的Excel表單中循環多個字符。這是做到這一點的正確方法嗎?附加的是這個特定功能和功能的API。 API 1API 2API 3我和f不是變量。將變量存儲到字符串

for row in data: 
    data_location, year_link, from_, to, max_value, min_value,digit = row[5:12] 
    output = 'From Bus #: {}\tTo Bus #: {}\tVMAX: {} pu\tVMIN: {} pu\t' 
     if year_link == year and data_location == location: 
     print(output.format(from_, to, max_value, min_value)) 

     psspy.two_winding_chng_4(from_,to,'%s'%digit,[_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f],[]) 
+0

嘗試將i和f賦值爲 –

+0

我不行。這些價值觀必須保持不變。對於數組的每個元素,某些值是不同的 – Mark

+0

如果值不同,則需要實際提供不同的值。它們是你的函數的輸入,你沒有定義它們 – user3080953

回答

0

的_i,_f,和_s分別是用於默認整數,浮點,和字符串值,佔位符。 PSSE API文檔在闡明這一點方面做得並不出色,但這些默認值將允許您自定義特定的函數參數,而無需爲每個參數分配一個值。

最簡單的方法是導入以下內容:

from psspy import _i 
from psspy import _f 
from psspy import _s 

或者,您可以添加以下幾行:

for row in data: 
    data_location, year_link, from_, to, max_value, min_value,digit = row[5:12] 
    output = 'From Bus #: {}\tTo Bus #: {}\tVMAX: {} pu\tVMIN: {} pu\t' 
     if year_link == year and data_location == location: 
     print(output.format(from_, to, max_value, min_value)) 
     _i = psspy.getdefaultint() 
     _f = psspy.getdefaultreal() 
     psspy.two_winding_chng_4(from_,to,'%s'%digit,[_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f,_f, max_value, min_value,_f,_f,_f],[]) 

我不知道呼籲_s,但畢竟是很少用於API函數中。希望這可以幫助。