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

时间:2021-02-27 12:58:13   收藏:0   阅读:0
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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!