01 2015 档案

摘要:6、collections 模块还提供有OrderedDict,用于获取有序字典import collectionsd = {'b':3, 'a':1,'x':4 ,'z':2}dd = collections.OrderedDict(d)for key, value in dd.items(): ... 阅读全文
posted @ 2015-01-24 11:51 第八片叶子 阅读(197) 评论(0) 推荐(0)
摘要:1、如果想得到一个列表的index和内容,可以通过enumerate快速实现drinks = ['coffee','tea', 'milk', 'water']for index, drink in enumerate(drinks): print ('Item {} is {}'.forma... 阅读全文
posted @ 2015-01-21 15:58 第八片叶子 阅读(277) 评论(0) 推荐(0)