# 编写装饰器 def wrapper(function): def _open(*args, **kw): """ 修改路径 """ args_list = list(args) key = '/'.join(__file__.split('\\')[:-1]) + '/' args_list[0] = key + args[0] if kw.get('file'): kw['file'] = key + kw['file'] return function(*args_list, **kw) return _open # 装饰内置函数open open = wrapper(open)
标签:python,OPEN,args,list,kw,file,open,装饰 From: https://www.cnblogs.com/comcom/p/17128105.html