类似问题(与Python2相关:)class A: return 'this is f'
return 'this is g'
在Python3中不再有instancemethod,一切都是函数,所以与Python2相关的答案将不再有效。正如我所说的,一切都是函数,所以我们可以调用A.f(0),但我们当然不能调用A.f() (参数不匹
我正在使用python。我想知道在同一模块中是否存在任何方法。我认为getattr()可以做到这一点,但我做不到。下面的示例代码说明了我真正想要做的事情。#python module is my_module.py # I want to check the existence of exists_methodif getattr(my_module, exists_method): return