📜  python 创建一个对角线为一个的矩阵 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:18.712000             🧑  作者: Mango

代码示例1
# Create a matrix in python and fill
import numpy as np
a = np.zeros((3, 3), int) # Create matrix with only 0
np.fill_diagonal(a, 1) # fill diagonal with 1
print(a)