有点困惑。这是你试图达到的目标吗?
import random
def GridSet():
fullGrid = []
letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
for j in range(10):
collect = []
for i in range(10):
collect_sub = []
collect_sub.append([letters[j] + repr(i+1), random.randrange(100)+1, 0])
collect.append(collect_sub)
fullGrid.append(collect)
return fullGrid
filledGrid = GridSet()
import pprint
pprint.pprint(filledGrid)
输出
[[[['A1', 12, 0]],
[['A2', 99, 0]],
[['A3', 91, 0]],
[['A4', 29, 0]],
[['A5', 72, 0]],
[['A6', 24, 0]],
[['A7', 99, 0]],
[['A8', 77, 0]],
[['A9', 39, 0]],
[['A10', 93, 0]]],
[[['B1', 54, 0]],
[['B2', 78, 0]],
[['B3', 12, 0]],
[['B4', 78, 0]],
[['B5', 79, 0]],
[['B6', 68, 0]],
[['B7', 80, 0]],
[['B8', 29, 0]],
[['B9', 60, 0]],
[['B10', 48, 0]]],
[[['C1', 59, 0]],
[['C2', 20, 0]],
[['C3', 4, 0]],
[['C4', 42, 0]],
[['C5', 91, 0]],
[['C6', 61, 0]],
[['C7', 28, 0]],
[['C8', 68, 0]],
[['C9', 18, 0]],
[['C10', 73, 0]]],
[[['D1', 9, 0]],
[['D2', 29, 0]],
[['D3', 81, 0]],
[['D4', 46, 0]],
[['D5', 49, 0]],
[['D6', 95, 0]],
[['D7', 64, 0]],
[['D8', 5, 0]],
[['D9', 26, 0]],
[['D10', 88, 0]]],
[[['E1', 62, 0]],
[['E2', 6, 0]],
[['E3', 35, 0]],
[['E4', 37, 0]],
[['E5', 54, 0]],
[['E6', 58, 0]],
[['E7', 85, 0]],
[['E8', 26, 0]],
[['E9', 76, 0]],
[['E10', 85, 0]]],
[[['F1', 38, 0]],
[['F2', 67, 0]],
[['F3', 32, 0]],
[['F4', 2, 0]],
[['F5', 76, 0]],
[['F6', 97, 0]],
[['F7', 34, 0]],
[['F8', 30, 0]],
[['F9', 58, 0]],
[['F10', 73, 0]]],
[[['G1', 68, 0]],
[['G2', 20, 0]],
[['G3', 60, 0]],
[['G4', 46, 0]],
[['G5', 89, 0]],
[['G6', 85, 0]],
[['G7', 76, 0]],
[['G8', 58, 0]],
[['G9', 86, 0]],
[['G10', 49, 0]]],
[[['H1', 22, 0]],
[['H2', 76, 0]],
[['H3', 50, 0]],
[['H4', 2, 0]],
[['H5', 6, 0]],
[['H6', 60, 0]],
[['H7', 92, 0]],
[['H8', 9, 0]],
[['H9', 26, 0]],
[['H10', 91, 0]]],
[[['I1', 57, 0]],
[['I2', 89, 0]],
[['I3', 1, 0]],
[['I4', 7, 0]],
[['I5', 25, 0]],
[['I6', 70, 0]],
[['I7', 40, 0]],
[['I8', 21, 0]],
[['I9', 7, 0]],
[['I10', 93, 0]]],
[[['J1', 77, 0]],
[['J2', 23, 0]],
[['J3', 24, 0]],
[['J4', 48, 0]],
[['J5', 17, 0]],
[['J6', 64, 0]],
[['J7', 11, 0]],
[['J8', 33, 0]],
[['J9', 23, 0]],
[['J10', 20, 0]]]]
如果缩进太深,您只需删除附加到的fullGrid
而不破坏其余部分的完整性。