标签:class style print href getattr cut exec please reg
class Account: func_lic = [‘login‘, ‘logout‘, ‘register‘] def login(self): print(‘login successful‘) def logout(self): print(‘logout successful‘) def register(self): print(‘register successful‘) def run(self): print(‘‘‘ please enter you want to execute method: 1. login 2. logout 3. register ‘‘‘) choice = int(input(‘enter method code: ‘)) func_name = Account.func_lic[choice-1] func = getattr(Account,func_name) func(self) # func = getattr(self, func_name) # func() obj1 = Account() obj1.run()
标签:class style print href getattr cut exec please reg
原文地址:https://www.cnblogs.com/sara20200116/p/12199759.html