返回: Python基础 索引页
希望形成如下的二维数组:
[Action --1][3] [Action --2][5] [Action --3][2] [Action --4][1] [Action --5][8] [Action --6][4]
以列表实现,代码如下:
simplist = [] tmpFactor= [] tmpFactor.append("[Action --1]") tmpFactor.append(3) simplist.append(tmpFactor) tmpFactor= [] tmpFactor.append("[Action --2]") tmpFactor.append(5) simplist.append(tmpFactor) tmpFactor= [] tmpFactor.append("[Action --3]") tmpFactor.append(2) simplist.append(tmpFactor) tmpFactor= [] tmpFactor.append("[Action --4]") tmpFactor.append(1) simplist.append(tmpFactor) tmpFactor= [] tmpFactor.append("[Action --5]") tmpFactor.append(8) simplist.append(tmpFactor) tmpFactor= [] tmpFactor.append("[Action --6]") tmpFactor.append(4) simplist.append(tmpFactor) print (simplist)
测试获得结果如下:
[['[Action --1]', 3], ['[Action --2]', 5], ['[Action --3]', 2], ['[Action --4]', 1], ['[Action --5]', 8], ['[Action --6]', 4]]
返回: Python基础 索引页