Convert numpy array to tuple

后端 未结 5 1680
北海茫月
北海茫月 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:37

    >>> arr = numpy.array(((2,2),(2,-2)))
    >>> tuple(map(tuple, arr))
    ((2, 2), (2, -2))
    

提交回复
热议问题