array=(1,2,3,4)
lenM = numpy.shape(array)
print lenM
(4,)
if len(lenM) == 1:
"1 dimensional code"
elif len(lenM) == 2:
"2 dimensional code"
len (lenM) will tell you if there are multiple dimensions in the array. If len (lenM) is 1, there is only one dimension. if the array has more than one dimension, lenM will have more than one element.
source
share