ppt课件-introductionto python(introductionto python).pptVIP

  • 8
  • 0
  • 约6.82千字
  • 约 25页
  • 2017-01-22 发布于四川
  • 举报

ppt课件-introductionto python(introductionto python).ppt

Example: closure def counter(start=0, step=1): x = [start] def _inc(): x[0] += step return x[0] return _inc c1 = counter() c2 = counter(100, -10) c1() 1 c2() 90 map def add1(x): return x+1 map(add1, [1,2,3,4]) [2, 3, 4, 5] map(lambda x: x+1, [1,2,3,4]) [2, 3, 4, 5] map(+, [1,2,3,4], [100,200,300,400]) map(+,[1,2,3,4],[100,200,300,400]) ^ SyntaxError: invalid syntax map + is an operator, not a function We can define a corresponding add function def add(x, y): return x+y map(add,[1,2,3,4],[100,200,300,400]) [101, 202, 303, 404] Or

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档