from types import MethodType, FunctionType
class Bar:
def foo(self):
pass
def foo2():
pass
def run():
print("foo 是函数", isinstance(Bar().foo, FunctionType))
print("foo 是方法", isinstance(Bar().foo, MethodType))
print("foo2 是函数", isinstance(foo2, FunctionType))
print("foo2 是方法", isinstance(foo2, MethodType))
if __name__ == '__main__':
run()
foo 是函数 False
foo 是方法 True
foo2 是函数 True
foo2 是方法 False
博客聚焦于如何判断一个对象是函数还是方法,虽未给出具体内容,但核心围绕此信息技术问题展开,旨在探讨相关判断方法。
102

被折叠的 条评论
为什么被折叠?



