【python基础】判断矩阵为空

code

import numpy as np
a=np.array([[2, 2, 3], [3, 5, 12]])
b=np.unique(a)
c = b>10
d = np.extract(c, b)
if np.any(d):
  print(d)

 

np.any(data)

若为空,返回 False

若不为空,返回 True

 

参考

1. 

posted on 2021-09-18 17:51  鹅要长大  阅读(744)  评论(0编辑  收藏  举报

导航