【题干描述】

Given a matrix A, return the transpose of A.

The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.(一矩阵A,返回其转置)

【思路】

  • 直接处理,A[i][j]的值赋值给output[j][i].

【python代码】

 input = [[1, 2, 3], [4, 5, 6]]
row = len(input)
col = len(input[0]) output = [[None]*row for _ in range(col)] for j in range(col):
for i in range(row):
output[j][i] = input[i][j]
print output

【所用python点】

  • range()和xrange()的区别:https://www.cnblogs.com/Sinkinghost/p/9320070.html
  • [[None]*row for _ in range(col)] 的 “_” 其实可以用 任意变量替换。
  • [None]*row 的结果是[None, None, None]

最新文章

  1. 大家是怎么做Code Review的?
  2. jQuery validate 验证隐藏域
  3. atitit.web的动态include 跟变量传递 java .net php
  4. java web基础1Tomcat服务器基本知识
  5. css3常用动画效果集合01
  6. 十六、mysql 分区之 简单sql优化2
  7. GridView多行标题行、改造标题行、自定义标题行完美版
  8. Android 内核初识(4)属性服务器
  9. iOS两个强制旋转屏幕的方法
  10. HDU5058
  11. asp.net mvc 防止重复提交
  12. P1339 [USACO09OCT]热浪Heat Wave
  13. Activemq -- Spring 整合
  14. python和linux如何学习一门新的编程语言(python)(python基础结构)
  15. oracle的学习笔记(转)
  16. javamail模拟邮箱功能--邮件回复-中级实战篇【邮件回复方法】(javamail API电子邮件实例)
  17. ES6 三层for循环的链式写法
  18. SQL Server Mobile/Compact Edition 简单介绍
  19. Orchard运用 - 为评论启用Gravatar头像
  20. 大前端涉猎之前后端交互总结2:使用PHP进行表单数据上传与更新

热门文章

  1. webpack+vue2实现旅游网小demo
  2. GPU 编程语言 Harlan
  3. linux socket中tcp的time_wait的快速回收和重用
  4. Python学习---Python数据类型1206
  5. Java实例---flappy-bird实例[最终版]
  6. database design three form
  7. 沉淀再出发:在python3中导入自定义的包
  8. discern concern fifth sixth
  9. Python 变量和数据类型
  10. 做 fzu oj 1003 简单的枚举