python_day016 scoping
作者:互联网
作用域练习1
def test1(): print('in the test1') def test(): print('in the test') return test1 res = test() print(res()) #res = test1地址 函数没有return,默认返回None
作用域练习2
name = 'alex' def foo(): name = 'lhf' def bar(): name = 'wupeiqi' print(name) return bar a = foo() print(a) a()
作用域练习3
name = 'alex' def foo(): name = 'lhf' def bar(): name = 'wupeiqi' print(name) def tt(): print(name) return tt return bar bar = foo() tt = bar() print(tt) print(tt()) #上面几句=print(foo()()())
标签:bar,name,python,tt,print,scoping,foo,day016,def 来源: https://www.cnblogs.com/yuyukun/p/10397854.html