We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a53b42 commit b4b1718Copy full SHA for b4b1718
doudou/2020-06-19-skills/skills.py
@@ -0,0 +1,15 @@
1
+def outer(x):
2
+ def inner(y):
3
+ # 在内函数中 用到了外函数的变量
4
+ nonlocal x
5
+ x += y
6
+ return x + y
7
+
8
+ # 外函数的返回值是内函数的引用
9
+ return inner
10
11
+fun = outer(10)
12
13
+print(fun(10)) # 30
14
+print(fun(10)) # 40
15
+print(fun(10)) # 50
doudou/README.md
@@ -19,6 +19,9 @@ Python技术 公众号文章代码库
19
+ [字符画](https://github.com/JustDoPython/python-examples/tree/master/doudou/2020-05-17-character-drawing):字符画
20
21
+ [迷宫](https://github.com/JustDoPython/python-examples/tree/master/doudou/2020-06-12-maze):迷宫
22
23
++ [Python 骚操作](https://github.com/JustDoPython/python-examples/tree/master/doudou/2020-06-19-skills):Python 骚操作
24
25
---
26
27
从小白到工程师的学习之路。
0 commit comments