【Python基础】构建三维数组的例子
构建三维数组,形如:
[Actin --1][0] [conditon aa] [conditon bb] [conditon cc] [Actin --2][0] [conditon dd] [conditon aa] [Actin --3][0] [conditon aa] [conditon kk] [conditon rr] [conditon cc]
测试代码如下:
simplist = [] tmpFactor= [] tmpFactor.append("[Action --1]") tmpFactor.append(0) contents = [] contents.append("conditon aa") contents.append("conditon bb") contents.append("conditon cc") simplist.append(tmpFactor) simplist.append(contents) tmpFactor= [] tmpFactor.append("[Action --2]") tmpFactor.append(0) contents = [] contents.append("conditon dd") contents.append("conditon aa") simplist.append(tmpFactor) simplist.append(contents) tmpFactor= [] tmpFactor.append("[Action --3]") tmpFactor.append(0) contents = [] contents.append("conditon aa") contents.append("conditon kk") contents.append("conditon rr") contents.append("conditon cc") simplist.append(tmpFactor) simplist.append(contents) ##KeyWord = [] ##KeyWord.append("condition aa") ##KeyWord.append("condition kk") ##KeyWord.append("condition cc")
输出结果:
print (simplist) [['[Action --1]', 0], ['conditon aa', 'conditon bb', 'conditon cc'], ['[Action --2]', 0], ['conditon dd', 'conditon aa'], ['[Action --3]', 0], ['conditon aa', 'conditon kk', 'conditon rr', 'conditon cc']]