摘要: 两种方法:1.声明法 2.模块法1.声明法在文件开始生命全局变量(为了区别,一般大写),在具体函数中,具体使用时,加上“global 变量名”。示例:import osimport sysA = 3B = 5def fuc(): global A global B print "fuc_A:" + str(A) print "fuc_B:" + str(B)if __name__ == "__main__": print "A:" + str(A) print "B:" + str(B) B + 阅读全文
posted @ 2013-05-10 23:53 jihite 阅读(3352) 评论(0) 推荐(0) 编辑