📜  python在对象上调用动态函数 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:38.533000             🧑  作者: Mango

代码示例1
obj = MyClass()
try:
    func = getattr(obj, "dostuff")
    func()
except AttributeError:
    print "dostuff not found"