且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python3:检查方法是否静态

更新时间:2023-11-28 22:50:58

class A:
  def f(self):
    return 'this is f'

  @staticmethod
  def g():
    return 'this is g'
print(type(A.__dict__['g']))
print(type(A.g))

<class 'staticmethod'>
<class 'function'>