gpt4 book ai didi

python - 在 float 数组中找到最小值

转载 作者:IT老高 更新时间:2023-10-28 22:13:02 26 4
gpt4 key购买 nike

如何在 python 的 100 个 float 的数组中找到最小值?我尝试了 minindex=darr.argmin()print darr[minindex]import numpy (darr 是数组的名称)

但我得到:minindex=darr.argmin()

AttributeError: 'list' 对象没有属性 'argmin'

可能是什么问题?有没有更好的选择?

提前致谢

最佳答案

Python 有一个 min() built-in function :

>>> darr = [1, 3.14159, 1e100, -2.71828]
>>> min(darr)
-2.71828

关于python - 在 float 数组中找到最小值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3499026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com