在IronPython 2.7.5中,我有一個返回字符串數組的函數(一個由其他人設計的backbox)。將數組連接成一個數組在ironPython 2.7.5上的.NET 4.0
函數在循環中調用。我需要逐個連接返回的數組。最終的類型也必須是一個字符串數組。
UPDATE
我的代碼:
def Myfunction():
in a For Loop:
data_array = Anotherfunction()
final_data_array += data_array
ThirdFunction(final_data_array) # the final data type MUST be array
我不知道如何爲數組做串聯。
因此,我將數組轉換爲列表,然後連接它們。
最後,我需要在.NET 4.0上的IronPython 2.7.5中將最終列表(保留所有restuls)轉換爲數組(它必須是數組,因爲它將用作lib函數的輸入參數)。
我的代碼:
from array import array
tt = ["abc", "def"]
array(','.join(tt))
我得到錯誤:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected character, got str
下面的代碼:
from array import array
tt = ["abc", "def"]
array(tt)
我得到錯誤:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected str, got list
我不能使用numpy和其他軟件包。或者,如何將數組併入一個數組?
我也試過:
array('c')
,但它僅用於字符。我需要
<type 'Array[str]'>
有什麼建議嗎?感謝
','.join(tt)的類型是str不是數組。 – Lily