关于“正交化”,可能这就是你要找的,
>>> li = [[1, 4, 4, 244, 263, 704, 952], [2, 4, 4, 215, 172, 305, 33], [3, 4, 4, 344, 279, 377, 1945], [4, 4, 4, 66, 79, 169, 150], [5, 4, 3, 16, 22, 247], [6, 4, 4, 17, 154, 93, 309], [7, 3, 2, 233, 311], [8, 3, 1, 15], [9, 3, 2, 55, 102]]
>>> def orthogonalize(li):
max_col = max(len(x) for x in li) + 1
for l in li:
for i in range(max_col-len(l)):
l.append(0)
>>> orthogonalize(li)
>>> li
[[1, 4, 4, 244, 263, 704, 952, 0], [2, 4, 4, 215, 172, 305, 33, 0], [3, 4, 4, 344, 279, 377, 1945, 0], [4, 4, 4, 66, 79, 169, 150, 0], [5, 4, 3, 16, 22, 247, 0, 0], [6, 4, 4, 17, 154, 93, 309, 0], [7, 3, 2, 233, 311, 0, 0, 0], [8, 3, 1, 15, 0, 0, 0, 0], [9, 3, 2, 55, 102, 0, 0, 0]]
>>> li[5]
[6, 4, 4, 17, 154, 93, 309, 0]
>>> li[6]
[7, 3, 2, 233, 311, 0, 0, 0]
>>>
根据您的附加要求进行编辑:
由于我的理解有限,我不得不做出假设,
您的数据是 2d 的,但您想使用 block#、line# 和 column# 在 3d 中访问它,因为我无法在您的数据中找到块标识符。你已经处理了你的数据
>>> def getData(data, block, line, column = None):
"""
Index start from 0 for block, line and column
getData(data, 0,1,1)
=> block# is 0 it will be processed as is
=> it will read value of line#1, column#1
getData(data, 1,1,1)
=> block# is 1 it will be convert to line number = 50*(block)+line
=> it will read value of line#51, column#1
"""
if column is None:
return data[50*(block)+line]
else:
return data[50*(block)+line][column]
>>> d = [[1, 4, 4, 244, 263, 704, 952, 0],
[2, 4, 4, 215, 172, 305, 33, 0],
[3, 4, 4, 344, 279, 377, 1945, 0],
............
[51, 4, 4, 244, 263, 704, 952, 0],
[52, 4, 4, 215, 172, 305, 33, 0],
[53, 4, 4, 344, 279, 377, 1945, 0],
[54, 4, 4, 66, 79, 169, 150, 0],
[55, 4, 3, 16, 22, 247, 0, 0],
[56, 4, 4, 17, 154, 93, 309, 0],
[57, 3, 2, 233, 311, 0, 0, 0],
[58, 3, 1, 15, 0, 0, 0, 0],
[59, 3, 2, 55, 102, 0, 0, 0],
[60, 4, 4, 304, 209, 307, 945, 0]]
>>> getData(d, 0, 0)
[1, 4, 4, 244, 263, 704, 952, 0]
>>> getData(d, 0, 0, 3)
244
>>> getData(d, 1, 0)
[51, 4, 4, 244, 263, 704, 952, 0]
>>> getData(d, 1, 0, 4)
263