摘要: # 装饰器,对一个函数打扮 # def foo():# print("foo")# foo# foo()# def test1():# print(' 1 ')# def test1():# print(' 2 ')# test1() # 需求来了 # 开放封闭规则# 封闭:以实现的功能代码块# 开 阅读全文
posted @ 2018-08-08 17:52 红尘陌上,独自行走 阅读(116) 评论(0) 推荐(0)
摘要: def test(): # 函数名中的test相当于一个变量名 print(' 1 ') # test() #调用这个函数 1 # # test #test指向了一个函数块,变量名指向了函数体 # print(test) # <function test at 0x000002BD550C7F28> 阅读全文
posted @ 2018-08-08 12:07 红尘陌上,独自行走 阅读(105) 评论(0) 推荐(0)
摘要: # 迭代器 # 迭代==再上一个版本的基础上,在更新一个版本 # 可迭代对象# 以直接作用于for循环的数据类型有以下几种:# 一类是集合数据类型: 如 list 、tuple、dict、set、str等# 一类是generator,包括生成器和带yield的generator function。# 阅读全文
posted @ 2018-08-08 10:44 红尘陌上,独自行走 阅读(90) 评论(0) 推荐(0)