python中zip()

# -*- coding: utf-8 -*-
"""
Created on Thu May 17 10:33:58 2018

@author: Loulch C.C
"""
"""
class zip(object)
 |  zip(iter1 [,iter2 [...]]) --> zip object
 |  
 |  Return a zip object whose .__next__() method returns a tuple where
 |  the i-th element comes from the i-th iterable argument.  The .__next__()
 |  method continues until the shortest iterable in the argument sequence
 |  is exhausted and then it raises StopIteration.
 |  返回一个zip对象,该对象的__next__()方法返回一个元组,其中第i个元素来自第i个可迭代的参数。
 |  __next__()方法继续,直到参数序列中最短的迭代被耗尽,然后增加停止迭代。
 |  
 |  Methods defined here:
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  __iter__(self, /)
 |      Implement iter(self).
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
 |  
 |  __next__(self, /)
 |      Implement next(self).
 |  
 |  __reduce__(...)
 |      Return state information for pickling.

"""
import numpy as np
for i,j in zip(np.arange(9),np.array(['a','b','c','d','e','f','g'])):
    print(i,j)
#输出:
#0 a
#1 b
#2 c
#3 d
#4 e
#5 f
#6 g

阅读更多
版权声明:本文为博主辛苦整理的文章,如有参考或转载,请注明出处。尊重别人劳动成果,尊重自己。 https://blog.csdn.net/Lelouc_CC/article/details/80347786
个人分类: python入门
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭