摘要:
global可以修改全局变量,但是要调用后才能生效,nonlocal一般使用在嵌套函数中可以修改外层函数局部变量,同样要调用才能生效。 global和nonlocal不能同时存在,如果在函数中使用global修饰了变量,那么在嵌套函数中用nonlocal修饰同名变量会发生报错,因为nonlocal表 阅读全文
posted @ 2021-07-29 13:40
冷眸d小胜
阅读(59)
评论(0)
推荐(0)
摘要:
类中函数实例化后就变成了方法类中函数直接通过类调用就是函数 阅读全文
posted @ 2021-07-29 13:30
冷眸d小胜
阅读(33)
评论(0)
推荐(0)
摘要:
class MethodTest: def inner_test(self): print('in class')def outer_test(): print('out of class')mt = MethodTest()mt.outer_test = outer_testmt.inner_te 阅读全文
posted @ 2021-07-29 13:28
冷眸d小胜
阅读(28)
评论(0)
推荐(0)
浙公网安备 33010602011771号