摘要: 一、什么是命名空间 命名空间就是存放变量名和函数名的空间。 如果你想访问一个变量值,必须先访问对应的命名空间,拿到名字和对应内存地址的绑定关系。 二、名称空间的分类 1、内置命名空间 python提前定义好的名字,就是存在于内置命名空间 2、全局命名空间 存放于文件级别的名字,就叫做全局命名空间 ( 阅读全文
posted @ 2019-11-11 15:11 GhostAnt 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 函数的嵌套 # 函数嵌套 def index(): print('from index') def home(): print('from home-1') index() print('from home-2') home() def compare(x, y): if x > y: return 阅读全文
posted @ 2019-11-11 14:47 GhostAnt 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 函数是第一类对象 1、函数名可以被引用 # 1、函数名可以被引用 def add(x, y): print(x + y) a = add a() 2、函数名可以当作参数传递 # 2、函数名可以当作参数传递 def add(x, y): print(x + y) def index(x, y, ope 阅读全文
posted @ 2019-11-11 14:33 GhostAnt 阅读(173) 评论(0) 推荐(0) 编辑