python常用包和模块-更新

random.sample(sequence, k),从指定序列中随机获取指定长度的片断。sample函数不会修改原有序列

numpy.nonzero() Return the indices of the elements that are non-zero.

>>> a = np.array([[1,2,3],[4,5,6],[7,8,9]])
>>> a > 3
array([[False, False, False],
       [ True,  True,  True],
       [ True,  True,  True]], dtype=bool)
>>> np.nonzero(a > 3)
(array([1, 1, 1, 2, 2, 2]), array([0, 1, 2, 0, 1, 2]))
原文地址:https://www.cnblogs.com/yuchenkit/p/5316860.html