Discuss / Python / 为什么我的不能调用?

为什么我的不能调用?

Topic source

董DHH董

#1 Created at ... [Delete] [Delete and Lock User]
#import functools
def log(func):
    #@functools.wraps(func)
    def wrapper(*args,**kw):
        print('bengin call')
        result=func(*args,**kw)
        print('end call')
        return result
    return wrapper

@log
def now():
    print('2016-11-29')

上面代码是.py中的。然后我在命令提示符窗口输入now(),并不能进行打印是因为什么

函数运行完return就会跳出来的。。

immatt9

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

因为你的代码在文件的缘故吧


  • 1

Reply