【发布时间】:2021-09-29 06:48:38
【问题描述】:
下面有一些代码
class Example:
def __init__(self,height,weight)
self.height = height
self.weight = weight
@staticmethod
def some_op(func)
def inner(*args,**kwargs)
s = func(*args,**kwargs)
print("Implementing function...")
@some_op
def num_op(self,values):
for value in values:
v = value * 10
q = v - 100
c = q ** -1
return c
example = Example()
values = [11,23123,1209,234]
example.num_op(values)
但它输出:
TypeError: 'staticmethod' object is not callable
我真的不知道类中的装饰器,所以我应该如何更改代码以使其返回:
Implementing function...
0.0004464285714285714
非常感谢!
【问题讨论】:
标签: python class error-handling static-methods python-decorators