返回列表 發帖

三維串列

  1. # 2x3x4
  2. list=[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],
  3.        [[13,14,15,16],[17,18,19,20],[21,22,23,24]]]
  4. for i in range(0,2):
  5.     for j in range(0,3):
  6.         for k in range(0,4):
  7.             print("list[%d][%d][%d]=%d"%(i,j,k,list[i][j][k]))
複製代碼

  1. l = [[[1,2,3,4],[5,6,7,8,],[9,10,11,12]],
  2.         [[13,14,15,16],[17,18,19,20],[21,22,23,24]]]

  3. for i in range(0,2):
  4.     for j in range(0,3):
  5.         for k in range(0,4):
  6.             print("list[%d][%d][%d]=%d"%(i,j,k,l[i][j][k]))
複製代碼

TOP

  1. m=[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],[[13,14,15,16],[17,18,19,20],[21,22,23,24]]]
  2. for i in range(len(m)):
  3.     for j in range(len(m[0])):
  4.         for k in range(len(m[0][0])):
  5.             print(f"list[{i}][{j}][{k}]={m[i][j][k]}")
複製代碼

TOP

返回列表