网络编程
位置:首页>> 网络编程>> Python编程>> python 寻找list中最大元素对应的索引方法

python 寻找list中最大元素对应的索引方法

作者:nov_csdn  发布时间:2021-02-16 07:37:52 

标签:python,list,索引

如下所示:


aa = [1,2,3,4,5]
aa.index(max(aa))

如果aa是numpy数组:


aa = numpy.array([1,2,3,4,5])

先把aa转换为List,再求索引:


bb = aa.tolist()
bb.index(max(bb))

来源:https://blog.csdn.net/Nov_csdn/article/details/52959346

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com