You can use .shape property too, which gives you a tuple containing the length of each dimension. Therefore, to get the dimension using .shape you could aswell call len() on the resulting tuple:
import numpy as np
a = np.array([1,2,3])
b = np.array([[1,2,3]])
c = np.array([[1,2,3],[2,4,6],[3,6,9]])
print("a={}".format(a))
print("a.shape: {}; len(a.shape): {}".format(a.shape, len(a.shape)))
print("b={}".format(b))
print("b.shape: {}; len(b.shape): {}".format(b.shape, len(b.shape)))
print(c)
print("c.shape: {}; len(c.shape): {}".format(c.shape, len(c.shape)))
Output:
a=[1 2 3]
a.shape: (3,); len(a.shape): 1
b=[[1 2 3]]
b.shape: (1, 3); len(b.shape): 2
[[1 2 3]
[2 4 6]
[3 6 9]]
c.shape: (3, 3); len(c.shape): 2