📜  替换矩阵值python代码示例

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

代码示例2
>>> import numpy as np
   >>> M = np.arange(10)
   >>> M
   array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
   >>> M[(M > 2) & (M < 7)] = -1
   >>> M
   array([ 0,  1,  2, -1, -1, -1, -1,  7,  8,  9])