2019-04-22
阅读量:
501
从数组中的给定值中找出最近的值
# 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)


暂无数据