使用Python程序创建3D列表。
3D列表表示3D阵列。在此程序中,我们使用整数元素创建3D数组。
示例
Input: 3× 3 × 2 [[1,1,1],[2,2,2],[3,3,3]], [[4,4,4],[5,5,5],[6,6,6]]
算法
Step 1: given the order of 3D list. Step 2: using for loop we create list and print data.
范例程式码
# Python program to created 3D list import pprint def print3D(i, j, k): lst = [[ ['*' for cc1 in range(i)] for cc2 in range(j)] for r in range(k)] return lst # Driver Code c1 = 3 c2 = 2 r = 2 # used the pretty printed function pprint.pprint(print3D(c1, c2, r))
输出结果
[[['*', '*', '*'], ['*', '*', '*']], [['*', '*', '*'], ['*', '*', '*']]]
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短