摘要: 迭代器根本上说, 迭代器就是有一个 next() 方法的对象迭代器可用内建的iter方法创建>>> i = iter('abc')>>> i.next()'a'>>> i.next()'b'>>> i.next()'c'对类可用__iter__和next()创建迭代器class Fib(object... 阅读全文
posted @ 2015-05-26 11:03 whu.yt 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 字典字典的创建>>> a = {'one': 1, 'two': 2, 'three': 3}>>> b = dict(one=1, two=2, three=3)>>> c = dict([('two', 2), ('one', 1), ('three', 3)])>>> a == b == cT... 阅读全文
posted @ 2015-05-26 10:58 whu.yt 阅读(166) 评论(0) 推荐(0) 编辑