如何使用混合的float和string元素来格式化vector以便从python转换为excel?

我使用Python 3.4并使用COM与Excel进行通信。

我想要使​​用python将vector转移到Excel。 当我顺序进行转移时,它工作正常。 1,“testing”和3出现在Excel Ws上。

但序列方法很慢,为了加快速度,我想一步转移载体。 喜欢

Range.value = (1,'Test',3) . 

当我这样做的时候,我看到Excel方面有三个1。 它与数据types有关,因为当我使用下面的格式化/数据types时,它工作正常。


 Range.value = ((1,),('Test'),(3,)) 

我想要做的是将一个200+的元素向量与数字和string混合在一起。 如何使用for循环创build具有上述工作格式的向量? 以下是我的testing程序。

 from win32com.client import Dispatch xlApp=Dispatch("Excel.Application") xlApp.visible=1 # xlApp.Workbooks.Add() Range = xlApp.ActiveWorkbook.ActiveSheet.Range("C2:C4") Range2 = xlApp.ActiveWorkbook.ActiveSheet.Range("C7;D9") vector=(1,'test3',3) # Elements transfered to Excel one by one xlApp.ActiveWorkbook.ActiveSheet.Range('C2').value = vector[0] xlApp.ActiveWorkbook.ActiveSheet.Range('C3').value = vector[1] xlApp.ActiveWorkbook.ActiveSheet.Range('C4').value = vector[2] print ('Elements transfered to Excel one by one:', vector) # Vector read from Excel vector2 = Range.value print('Elements read from Excel using vector: ',vector2) # Elements transfered to Excel using vector Range.value = vector print('Elements transfered to Excel using vector: ',vector) # Element read from Excel using vector vector3 = Range.value print('Elements transfered from Excel using vector: ',vector3) # Elements transfered to/from Excel using vector with another data type Range.value = ((1,),('test5',),(3,)) print('Elements transfered to/from Excel using vector with another data type: ',Range.Value)