#!/usr/bin/env python
# -*- coding: utf-8 -*-
def printList(datalist = []):
for i in range(len(datalist)):
print datalist[i]
def mergeList(list1, list2 = []):
if len(list1) == 0:
return list2
if len(list2) == 0:
return list1
list3 = []
for list1_i in range(len(list1)):
for list2_i in range(len(list2)):
list3_item = str(list1[list1_i]) + '-' + str(list2[list2_i])
list3.append(list3_item)
return list3
def row2columnList(datalist = []):
list_cr = [[]]
for col in range(len(datalist[0])):
list_tmp = []
for row in range(len(datalist)):
list_tmp.append(datalist[row][col])
list_cr.append(list_tmp)
return list_cr
def traversalPath(datalist = []):
list_tmp = []
for row in range(len(datalist)):
list_tmp = mergeList(list_tmp, datalist[row])
return list_tmp
if __name__=='__main__':
M = [['a1', 'b1', 'c1', 'd1', 'e1'],['a2', 'b2', 'c2', 'd2', 'e2'],['a3', 'b3', 'c3', 'd3', 'e3']]
M_tmp = row2columnList(M)
tp_list = traversalPath(M_tmp)
printList(tp_list)
print len(tp_list)
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。