python中取得矩阵中最大元素的位置
2015-10-25 14:01
561 查看
""" Create by 2015-10-25 @author: zhouheng In this function you can get the position of the element that you want in the matrix. """ import numpy as np def getPositon(): a = np.mat([[2, 5, 7, 8, 9, 89], [6, 7, 5, 4, 6, 4]]) raw, column = a.shape# get the matrix of a raw and column _positon = np.argmax(a)# get the index of max in the a print _positon m, n = divmod(_positon, column) print "The raw is " ,m print "The column is ", n print "The max of the a is ", a[m , n] getPositon()这是求的矩阵中最大元素的所在的行与列的python程序,希望对大家有帮助
相关文章推荐
- 关于Python中的classmethod
- 关于python中的property
- Python目录常用操作
- python实现发送邮件
- python socket 选项
- Python实现获取域名所用服务器的真实IP
- Python 中的进程、线程、协程、同步、异步、回调
- python爬虫-第一步,获取页面
- Python traceback【转】
- Python常见异常问题
- Python制作爬虫采集小说
- Python验证企业工商注册码
- 归并排序和快速排序比较
- python 多线程和多进程的区别 mutiprocessing theading
- python 机器学习——从感知机算法到各种最优化方法的应用(python)
- Python代码的多线程改造
- [python爬虫] Selenium定向爬取虎扑篮球海量精美图片
- 【从零开始】Python3 学习笔记
- python版贪食蛇snake
- 使用Python工具抓取网页