
python学习
丛林-漫步
这个作者很懒,什么都没留下…
展开
-
python学习:zip函数
一、定义: zip([iterable, …]) zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),然后返回由这些tuples组成的list(列表)。若传入参数的长度不等,则返回list的长度和参数中长度最短的对象相同。利用*号操作符,可以将list unzip(解压)。注意: zip()函数在python3 中返回的是原创 2017-02-20 16:08:56 · 696 阅读 · 0 评论 -
python3 sorted()的用法
python3中sorted函数取消了对cmp的支持(为了提高性能),现在Python3中sorted()函数的原型为: sorted(iterable, key=None, reverse=False) Return a new list containing all items from the iterable in ascending order.A custom key fun原创 2017-02-21 17:04:06 · 2891 阅读 · 0 评论