#第一层
class Student:
def __init__(self,name):
self.name = name
def show_course(self):
print('调用了 show course')
def select_course(self):
print('调用了 select course')
def quit(self):
print('调用了 quit')
wu = Student('伍佰')
while True:
name = input('>>>')
if hasattr(wu, name):
getattr(wu, name)()
# 使用反射
# alex = Manager('alex')
# operate_lst = [('创建课程','create_course'),('创建学生账号','create_student'),
# ('查看所有课程','show_courses'),('查看所有学生','show_students')]
# for index,opt in enumerate(operate_lst,1):
# print(index,opt[0])
# num = input('请输入您要做的操作 :')
# if num.isdigit():
# num = int(num)
# if hasattr(alex,operate_lst[num-1][1]):
# getattr(alex,operate_lst[num-1][1])()