![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
虾米小匠
这个作者很懒,什么都没留下…
展开
-
【转】zip的使用
zip函数接受任意多个(包括0个和1个)序列作为参数,返回一个tuple列表。具体意思不好用文字来表述,直接看示例:示例1x = [1, 2, 3]y = [4, 5, 6]z = [7, 8, 9]xyz = zip(x, y, z)print xyz 运行的结果是: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]示例2x = [1, 2, 3]y = [转载 2017-02-11 09:43:40 · 366 阅读 · 0 评论 -
Python CookBook笔记——数据结构与算法
解压序列复制给变量一、把含n个元素的数组赋值个n个变量p = (4,5)x,y = pstr = "x = {x}, y = {y}"print(str.format(x = x, y = y)) 输出结果: ‘x = 4,y = 5’二、解压不确定元素个数的对象p = (4,5,6,7,8,9,10)x,y,*final = pprint(x)print(y)print(原创 2017-02-12 13:06:31 · 253 阅读 · 0 评论