Convert numpy array to tuple

后端 未结 5 1679
北海茫月
北海茫月 2020-12-07 11:12

Note: This is asking for the reverse of the usual tuple-to-array conversion.

I have to pass an argument to a (wrapped c++) function as a nested tupl

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 11:30

    Another option

    tuple([tuple(row) for row in myarray])
    

    If you are passing NumPy arrays to C++ functions, you may also wish to look at using Cython or SWIG.

提交回复
热议问题