关于python修饰器调用报错问题

2024-05-28 16:57:25 (21分钟前 更新) 423 6698
<"..
>stdin>以下代码自定义了一个函数tsfunc.:
;>. pass

提示如下异常

>.,作为foo函数的修饰器
>
TypeError;>. return func()
;>., in <., called"..,func. print ", line 1;.;%s;> def tsfunc(func); %(ctime();module>.,%s..__name__)
:
File " @tsfunc
: '> foo()
Traceback (most recent call last). def foo();NoneType':
;>

最新回答

print 

你装饰器的用法不对.__name__)
 ,  func(*args;  :


====

def  ,func;*args;called"%(ctime();**kwargs), ,%s;%s, " :
 , tsfun(func,你要的功能大概的写法如下
print 

你装饰器的用法不对.__name__)
 ,  func(*args;  :


====

def  ,func;*args;called"%(ctime();**kwargs), ,%s;%s, " :
 , tsfun(func,你要的功能大概的写法如下
candyfloss365 2024-05-28
不要再shell里用装饰器,在编辑器里写,然后执行就没错了
不要再shell里用装饰器,在编辑器里写,然后执行就没错了
闪电小白猫 2024-05-25

扩展回答

1

关于python修饰器调用报错问题

<"..
>stdin>以下代码自定义了一个函数tsfunc.:
;>. pass

提示如下异常

>.,作为foo函数的修饰器
>
TypeError;>. return func()
;>., in <., called"..,func. print ", line 1;.;%s;> def tsfunc(func); %(ctime();module>.,%s..__name__)
:
File " @tsfunc
: '> foo()
Traceback (most recent call last). def foo();NoneType':
;>

4

python 修饰符@的问题,不太理解。

ython中的@修饰符应该怎么理解,感觉好难。大牛能指点一下吗,或者推荐一下那本书有详细的介绍修饰符的python书籍不
问题补充:一些好的博客也是可以的

热门问答

装修专题

其他人还看了

页面运行时间: 0.32645988464355 秒