08 2018 档案

摘要:def myDecorator(...): #定义装饰器,可能带参数 def decorator(func): #装饰器核心,以被装饰的函数对象为参数,返回装饰后的函数对象 def wrapper(*args, **kvargs): #装饰的过程,参数列表适应不同参数的函数 ... #修改函数调用前 阅读全文
posted @ 2018-08-30 16:39 alsoalso 阅读(115) 评论(0) 推荐(0)
摘要:d = path.dirname(__file__) #返回当前文件所在的目录 # __file__ 为当前文件获得某个路径的父级目录: parent_path = os.path.dirname(d) #获得d所在的目录,即d的父级目录 parent_path = os.path.dirname( 阅读全文
posted @ 2018-08-13 17:36 alsoalso 阅读(4910) 评论(0) 推荐(0)
摘要:import sys funcName = sys._getframe().f_back.f_code.co_name #获取调用函数名lineNumber = sys._getframe().f_back.f_lineno #获取行号 print sys._getframe().f_code.co 阅读全文
posted @ 2018-08-09 23:12 alsoalso 阅读(885) 评论(0) 推荐(1)
摘要:A=lambda x:x+1 def A(x):return x+1 冒号左边→想要传递的参数冒号右边→想要得到的数(可能带表达式) 阅读全文
posted @ 2018-08-09 18:25 alsoalso 阅读(198) 评论(0) 推荐(0)
摘要:class Cmd:# def __init__(self,name):# self.name = name def run(self): while 1: cmd = input('>>清输入命令>>').strip() if hasattr(self,cmd): func = getattr(s 阅读全文
posted @ 2018-08-06 23:08 alsoalso 阅读(207) 评论(0) 推荐(0)