2016-10-27 4 views

답변

0

하나 개 루프를 수행하려는 경우, 그냥 감소 드롭 루프를 수행

xs, ys, zs = [], [], [] 
for point in points: 
    xs.append(point.x) 
    ys.append(point.y) 
    zs.append(point.z) 

은 우편으로 더 간결하게 수행 할 수 있습니다

>>> points = [types.SimpleNamespace(x=it, y=it+1, z=it*2+1) for it in range(3)] 
>>> points 
[namespace(x=0, y=1, z=1), namespace(x=1, y=2, z=3), namespace(x=2, y=3, z=5)] 
>>> list(zip(*((point.x, point.y, point.z) for point in points))) 
[(0, 1, 2), (1, 2, 3), (1, 3, 5)]