2019-04-22
阅读量:
624
从数组中的给定值中找出最近的值
# numpy.ndarray.flat
# A 1-D iterator over the array.
# This is a numpy.flatiter instance, which acts similarly to, but is not a subclass of, Python’s built-in iterator object.
Z = np.random.uniform(0,1,10)
z = 0.5
m = Z.flat[np.abs(Z-z).argmin()]
print m
0.494656507792
0.0000
0
0
关注作者
收藏
评论(0)
发表评论
暂无数据

