码迷,mamicode.com
首页 > 编程语言 > 详细

python中zip的用法

时间:2020-12-31 12:01:00      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:返回   dac   python   bsp   可迭代对象   元组   span   对象   ddd   

 

zip()用于返回各个可迭代对象共同组成的元组。

>>> test1=["ccc","aaa","ddd","yyy","xxx"]
>>> test2=(200,100,400,800,500)
>>> test3="daceb"
>>> for i in zip(test1,test2,test3):
    print(i)

    
(ccc, 200, d)
(aaa, 100, a)
(ddd, 400, c)
(yyy, 800, e)
(xxx, 500, b)
>>> for i in zip(test1,test2):
    print(i)

    
(ccc, 200)
(aaa, 100)
(ddd, 400)
(yyy, 800)
(xxx, 500)
>>> for i in zip(test1,test3):
    print(i)

    
(ccc, d)
(aaa, a)
(ddd, c)
(yyy, e)
(xxx, b)
>>> for i in zip(test1,test2,test3):
    print(i,end="_")

    
(ccc, 200, d)_(aaa, 100, a)_(ddd, 400, c)_(yyy, 800, e)_(xxx, 500, b)_
>>> for i in zip(test1,test3):
    print(i,end="!")

    
(ccc, d)!(aaa, a)!(ddd, c)!(yyy, e)!(xxx, b)!

 

python中zip的用法

标签:返回   dac   python   bsp   可迭代对象   元组   span   对象   ddd   

原文地址:https://www.cnblogs.com/liujiaxin2018/p/14192846.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!