sum = 0 for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: sum = sum + x print(sum) 代码如上,但是运行报错: 发现是因为少了缩进,改正为如下: sum = 0 for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: sum = sum + x print(sum) 就没得问题了. 运行为: 但是若在改正代码格式: sum = 0 for x in [1, 2, 3, 4, 5, 6, 7, 8, 9,
[0. Brief introduction of block] Block是iOS4.0+ 和Mac OS X 10.6+ 引进的对C语言的扩展,用来实现匿名函数的特性. 用维基百科的话来说,Block是Apple Inc.为C.C++以及Objective-C加入的特性,使得这些语言能够用类lambda表达式的语法来创建闭包. 用Apple文档的话来说,A block is an anonymous inline collection of code, and sometimes also