- 博客(2)
- 收藏
- 关注
原创 python的生成器
今天看了看生成器,有个要点,做个记录。 G=( c*4 for c in 'asdf') I=iter(G) next(I) next(I) next(I) next(I) next(I) 此时抛出异常没因为已经没有迭代对象了。但是实际上 next(G)也是可行的,不这么做的原因只有一个:如果这么做了,迭代到最后,假如还要使
2015-12-17 19:21:05
337
原创 python函数的属性
最近看learn python,看到使用函数属性完成nonlocal的效果。def test(start): def nest(label): print(label,nest.state) nest.state+=1 nest.state=start return nest 个人觉得这是排版错误。应该如下: def test(start): def nest(labe
2015-12-16 18:49:29
980
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人