我想用静态方法制作装饰器,得到TypeError: 'staticmethod' object is not callable
这是我的静态方法
@staticmethod
def error_handling(func):
try:
func()
except KeyError:
return 'Appid does not exist'
except KeyboardInterrupt:
return 'User canceled the operation '
以及我的装饰器示例
@error_handling
def type(self, appid): # This method will return an appid's type (game or dlc)
"""
This method will return an appid's type (game or dlc)
:param appid: str or int
:return: str
"""
response = self.get_request(appid)
return response.json()[f'{appid}']['data']['type']