冬西

导航

2019年12月23日 #

函数作用域global和nonlocal

摘要: 函数作用域 自己有用自己的 自己没有用上一层 一层一层往上找: num = 0 def one(): print(num) #自己没有且没有上一层了用全局 0 num = 1 def two(): num =2 def three(): print(num)#自己没有往上找 2 three() pr 阅读全文

posted @ 2019-12-23 15:35 冬西 阅读(225) 评论(0) 推荐(0) 编辑