我需要在cdef函數中將int列表的Python列表轉換爲vector [int]以調用另一個C函數。我嘗試這樣做:在Python中將Python列表轉換爲向量<int>
cdef pylist_to_handles(hs):
cdef vector[int] o_vect
for h in hs:
o_vect.push_back(h)
return o_vect
這應該工作,因爲我只需要從其它CDEF函數調用它,我得到這個錯誤:
Cannot convert 'vector<int>' to Python object
我在做什麼錯?