I would harness numpy.diagflat combined with numpy.flip following way: import numpy as np arr = np.diagflat([1,1,1],2) # now we have 1s in ...
確定! 回上一頁