0
def zip(*iterables):
# zip('ABCD', 'xy') --> Ax By
sentinel = object()
iterators = [iter(it) for it in iterables]
while iterators:
result = []
for it in iterators:
elem = next(it, sentinel)
if elem is sentinel:
return
result.append(elem)
print(elem)
yield tuple(result)
사용 :파이썬 - 이해 우편
list(zip('abc','def'))
출력 :
a
d
b
e
c
f
[('a', 'd'), ('b', 'e'), ('c', 'f')]
질문 : 이유는 무엇입니까 'D' 'A'가 아닌 'B'후 전달받을 ?
는 모든 각각의 i 번째 엘리먼트에 전달 반복 가능한 병합. – M4rtini
요소, 첫 번째 요소, 두 번째 요소 등을 서로 짝 지어줍니다. 왜 ''가 ''b ''에 추가됩니까? –
[지퍼 그림] (http://en.wikipedia.org/wiki/Zipper) – jfs