Discuss / Python / 喜欢简单的代码,所以一次搞定全部结果

喜欢简单的代码,所以一次搞定全部结果

Topic source

杨飞wb

#1 Created at ... [Delete] [Delete and Lock User]

一次实现所有的效果,哼哼。。。

#!/usr/bin/env python
# -*- coding: utf-8 -*-

def begin():
    print('begin call')


def end():
    print('end call')


def log(func):
    def test():
        def fu():
            print('exec function name: %s' % func.__name__)
            return func()
        return begin(), fu(), end()
    return test


@log
def fc():
    print('yes')

fc()

输出:

C:\Python34\python.exe E:/Python_projects/testweb/test.py begin call exec function name: fc yes end call

Process finished with exit code 0


  • 1

Reply