class类反射的用法--getattr()


aa="test1"
class A:
    def test1(self):
        print("test1")
    def test2(self):
        print("test2")
    def test3(self):
        print("test3")
a=A()
func=getattr(a,aa)
func()

#test1