📜  嵌套循环 - 任何代码示例

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

代码示例3
def something(a):
    for methodname in ['method1', 'method2', 'method3']:
        try:
            m = getattr(a, methodname)
        except AttributeError:
            pass
        else:
            return m()
    raise AttributeError