Home > Back-end >  How to convert a tuple of an array to a tuple of integers
How to convert a tuple of an array to a tuple of integers

Time:10-18

suppose there's a tuple of an array.

In[1]: a

Out[1]: (array([0, 1]),)

how can it be converted to a tuple of integers like (0,1)?

CodePudding user response:

Make a tuple of the first element:

>>> import numpy as np
>>> a = np.array([0,1]),
>>> a
(array([0, 1]),)
>>> tuple(a[0])
(0, 1)
  • Related