【发布时间】:2016-12-09 19:21:59
【问题描述】:
我需要找到一种方法来计算从 0 到 9 的每个数字在使用 np.random.randint() 创建的随机矩阵中出现的次数
import numpy as np
p = int(input("Length of matrix: "))
m = np.random.randint(0,9,(p,p))
print(m)
例如,如果矩阵的长度 = 4
- [[3 4 6 5] [3 4 4 3] [4 2 4 8] [6 8 2 7]]
数字 4 出现了多少次?它应该返回 5。
【问题讨论】:
-
首先,弄清楚你将如何手工完成。
标签: python python-3.x numpy count