翻阅古今
这是我初始化列表列表的方式。行的变化最慢。nrows = 3; ncols = 5l_of_ls = [[0]*ncols for i in range(nrows )]for rix, r in enumerate(l_of_ls): for cix, c in enumerate(r): print rix, cix, 'val = ',c结果0 0 val = 00 1 val = 00 2 val = 00 3 val = 00 4 val = 01 0 val = 01 1 val = 01 2 val = 01 3 val = 01 4 val = 02 0 val = 02 1 val = 02 2 val = 02 3 val = 02 4 val = 0 还值得注意的是用于索引目的for rix in range(nrows): for cix in range(ncols): print l_of_ls[rix][cix], print结果0 0 0 0 00 0 0 0 00 0 0 0 0