返回顶部

收藏

Global variables

更多
# global scope
X = 99                # X and func assigned in module: global

def func(Y):          # Y and Z assigned in function: locals
    # local scope
    Z = X + Y         # X is not assigned, so it's a global
    return Z

func(1)               # func in module: result=100

标签:Python,基础

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2012-11-05 21:59:42java获得随机数代码 by 怪兽狂殴奥特曼
  2. 2013-05-01 10:33:52python小数除法取整数部分 by 甄码农
  3. 2014-11-14 14:14:58生成四位不重复数字(0-9)的所有组合 by wubai
  4. 2014-11-29 11:34:27getEncodedRange 方法一例 by 蟋蟀MM
  5. 2014-12-02 12:29:47python 登陆 gfan打卡 by 司马
  6. 2014-12-07 11:56:08Logistic Regression by wubai
  7. 2015-12-12 12:33:52Print module infomation by 大猪
  8. 2016-01-31 20:35:56Define and use Module: import by wubai
  9. 2016-02-14 09:34:09While with break by 风云轩
  10. 2016-03-13 14:57:35For loop combined with in function by 司马
  11. 2016-03-20 11:47:55Cheap and simple API helper by Solon.Ring

发表评论