间接
import numpy as np
all_true = np.zeros((3, 4)) == 0
all_false = np.zeros((3, 4)) != 0
直接
import numpy as np
all_true = np.full((3, 4), True, dtype=bool)
all_false = np.full((3, 4), False, dtype=bool)
参考
- https://www.it1352.com/1686226.html
- https://www.numpy.org.cn/reference/routines/array-creation.html#ones-%E5%92%8C-zeros-%E5%A1%AB%E5%85%85%E6%96%B9%E5%BC%8F