python elective system demo little exercise

# Simplify elective system code: the first landing, and then determine the identity and instantiated, based on the identity of the corresponding class, allowing users to select the 
class Manager: 
    operate_dict = [ 
        ( ' create a student account ' , " creat_student " ), 
        ( ' view student information ' , " check_student " ) 
                 ] 
    DEF  __init__ (Self, name): 
        self.name = name
     DEF creat_student (Self):
         Print ( ' create an account students ' )
     DEF check_student (Self):
        Print ( ' view student information ' ) 

class Student:
     DEF  __init__ (Self, name): 
        self.name = name
     DEF the Check (CLS):
         Print ( ' View course ' )
     DEF the Login (CLS):
         Print ( ' login ' ) 

class Teacher:
     DEF  the __init__ (Self, name): 
        the self.name = name
 DEF Login (): 
    username = INPUT ( ' User: ')
    password=input('password:')
    with open('userinfo')as f:
        for line in f :
            user,pwd,ident=line.strip().split('|')
            if user==username and pwd==password:
                print('登陆成功')
                return username,ident
import sys
def main():
    usr,id=login()
    file=sys.modules['__main__']
    cls=getattr(file,id)
    obj=cls(usr)
    Operate_dict=cls.operate_dict
    print(Operate_dict)
    for num,item in enumerate(Operate_dict):
        print(num,item[0])
    choice=int(input("num>>>"))
    choice_item=Operate_dict[choice-1]
    getattr(obj.choice_item[1])()
main()

The next part of the analysis focused

The first followed the written analysis is foggy. May also update it (?)

Guess you like

Origin www.cnblogs.com/jsacm/p/11451421.html