摘要: # class Test(object): # def __call__(self): # print(' test ') # t= Test()# t() 调用主要有个__call__方法 # __new__ __init__ __del__ __str__ __slots__ __call__ 阅读全文
posted @ 2018-08-09 15:28 红尘陌上,独自行走 阅读(154) 评论(0) 推荐(0) 编辑
摘要: # 以c语言为主是静态语言,运行之前先编译,在运行的过程中不允许编辑代码# 在运行的过程中,可以改变,可以添加属性,就是属于动态语言(python) # python动态的添加属性以及方法class Test(object): pass # t = Test()# print(dir(t)) # 运 阅读全文
posted @ 2018-08-09 12:13 红尘陌上,独自行走 阅读(642) 评论(0) 推荐(0) 编辑
摘要: 什么是命名空间 == 对一个名字起作用的范围 # def test():# print(" test ") # import test# test.test() # from test import * # LEGB规则 locals > enclosing function > globals > 阅读全文
posted @ 2018-08-09 11:44 红尘陌上,独自行走 阅读(86) 评论(0) 推荐(0) 编辑
摘要: # 使用装饰器对有返回值的函数进行装饰# def func(functionName): # print(' func-1 ') # def func_in(): # print(" func_in 1-") # x = functionName() #保存返回来的hahah # print(" f 阅读全文
posted @ 2018-08-09 11:23 红尘陌上,独自行走 阅读(174) 评论(0) 推荐(0) 编辑
摘要: # 使用装饰器无参数的函数进行装饰# def func(funcionName): # print(' 1 ') # def func_in(): # print('--func_in ') # funcionName() # print('--func_2 ') # print(' 2 ') # 阅读全文
posted @ 2018-08-09 10:04 红尘陌上,独自行走 阅读(133) 评论(0) 推荐(0) 编辑