代码:
import numpy as np
a = np.array([[6,3,8],[5,8,3],[3,5,2]])
b = np.zeros((3,3))
b[a>4] = True
print(b)
输出:
emulated/0/qpython/4.py" && exit <
[[1. 0. 1.]
[1. 1. 0.]
[0. 1. 0.]]
#[QPython] Press enter to exit ...
代码:
import numpy as np
a = np.array([[6,3,8],[5,8,3],[3,5,2]])
b = np.zeros((3,3))
b[a>4] = True
print(b)
输出:
emulated/0/qpython/4.py" && exit <
[[1. 0. 1.]
[1. 1. 0.]
[0. 1. 0.]]
#[QPython] Press enter to exit ...