开局一张图总结关系 一.列表解析式 我们习惯生成列表通过list = [1, 2, 3]的方式.还有一种很方便的列表生成方式 list = [a*2 for a in range(10)],或者list = [fun(a) for a in range(10)]都是可以的 >>> L1 = [a*2 for a in range(10)] >>> L1 [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] 如果只是生成一个100元素,1000元素的列表…
最近看ruby cookbook遇到这个用法,google一下,这里原文解释 http://stackoverflow.com/questions/18865860/enumerator-yielder-yield-vs-proc-yield Enumerator yielder.yield VS Proc.yield The yield statement has no receiver. Inside a method it means "Run the block right now&qu…