[Python]反射练习
class Foo:
def run(self):
while True:
cmd=input('cmd>>: ').strip()
# print('%s run...' %cmd)
if hasattr(self,cmd):
func=getattr(self,cmd)
func()
def download(self):
print('download....')
def upload(self):
print('upload...')
obj = Foo()
obj.run()