【发布时间】:2017-06-14 17:53:28
【问题描述】:
我有这个代码:
class A(object):
@staticmethod
def open():
return 123
@staticmethod
def proccess():
return 456
switch = {
1: open,
2: proccess,
}
obj = A.switch[1]()
当我运行它时,我不断收到错误:
TypeError: 'staticmethod' object is not callable
如何解决?
【问题讨论】:
-
@melpomene:哎呀,我不知道为什么我错过了。
-
@melpomene:不完全是骗子,
staticmethod对象有不同的(更多)选项。 -
@MartijnPieters 哦,我没有意识到问题标题与正文中的错误消息不匹配。
标签: python