说明
python中万物皆对象,函数也是对象,因此可以在A函数中给B函数(函数也是个对象)里面的成员赋值,尽管这个成员没有在B函数中声明或定义。
传值方法
#coding:utf-8
def fun1():
print fun1.x
print fun1.y
def fun2():
fun1.x=1
fun1.y=2
fun1.z=3
fun1()
fun2()
python中万物皆对象,函数也是对象,因此可以在A函数中给B函数(函数也是个对象)里面的成员赋值,尽管这个成员没有在B函数中声明或定义。
#coding:utf-8
def fun1():
print fun1.x
print fun1.y
def fun2():
fun1.x=1
fun1.y=2
fun1.z=3
fun1()
fun2()