class Cmd:
# def __init__(self,name):# self.name = name def run(self): while 1: cmd = input('>>清输入命令>>').strip() if hasattr(self,cmd): func = getattr(self,cmd) func() def ls(self): print('ls--->func') def pwd(self): print('pwd--->func') def cat(self): print('cat--->func')cmd = Cmd()cmd.run()