作用域
python/js语言中,无块级作用域 if 1 == 1: name = ‘alex‘ print(name) python中以函数为作用域 def func(): name = ‘alex‘ print(name) 作用域链, name = ‘alex‘ def f1(): print(name) def f2(): name = ‘Eric‘ f1() f2()
时间: 2024-10-13 04:19:04
作用域
python/js语言中,无块级作用域 if 1 == 1: name = ‘alex‘ print(name) python中以函数为作用域 def func(): name = ‘alex‘ print(name) 作用域链, name = ‘alex‘ def f1(): print(name) def f2(): name = ‘Eric‘ f1() f2()