如果我有一个这样的数组:
inner_loop = [ [ [18, 119], [42, 119], [42, 95], [18, 95] ], [ [80, 96], [80, 75], [59, 75], [59, 96] ] ]
我如何将其转换为多维元组
( ( (18, 119), (42, 119), (42, 95), (18, 95) ), ( (80, 96), (80, 75), (59, 75), (59, 96) ) )
我试过了:
tuple(tuple(y) for y in (tuple(tuple (x) for x in (tuple(inner_loops)))))
但最后一级没有转换.
tuple(tuple(tuple(l2) for l2 in l1) for l1 in inner_loop)