3
我有一個python函數,如下所示。我想在C#中調用函數並傳遞2個列表參數?它返回一個排名列表。這是可能的和如何?感謝您的幫助從C調用python函數#
function ranking_option() #accepts two arguments:
def Ranking_Options(costs, savings):
##Lets us form a list of list from the supplied data
rearranged_list = sorted([[costs[i], savings[i]] for i in range(len(costs))], reverse=False)
rankedlist = [rearranged_list[0]] #We form a new list of the ranked data coordinates
#Examine the sorted list one by one
for pair in rearranged_list[1:]:
if pair[0]>=rankedlist[-1][0] and pair[1]>=rankedlist[-1][1]:
rankedlist.append(pair)
if rankedlist[-2][0]==rankedlist[-1][0] and rankedlist[-2][1]<=rankedlist[-1][1]:
rankedlist[-2],rankedlist[-1]=rankedlist[-1],rankedlist[-2]
else:
if pair[0]==rankedlist[-1][0] and pair[1]>=rankedlist[-1][1]:
rankedlist[-1]=pair
rankedlist.append(pair)
return rankedlist
你應該看看IronPython http://ironpython.net/ –
爲什麼不用C#重寫它?這樣你可以引入一些令人討厭的類型,而不是一直依賴數組。 –