I defined a simple business card management system as a function.
2 layers.
a login interface;
A business card management system using the interface;
The logic is: Login success = "Jump into the business card system using the interface, at the same time, jump out of the login interface, give welcome to use, the program ends."
At this point: from the business card system using the interface to jump out, should be logged out, the result, that is to say, the first layer will jump out, the second layer now
1 defMingpian ():2Name = []3NAME_FL =04 whileNAME_FL = =0:5 Print("="*50)6 Print("Welcome to the card management system V1.0")7 Print("1: Add a business card")8 Print("2: Modify a business card")9 Print("3: Delete a business card")Ten Print("4: Query a business card") One Print("5: Exit") A Print("="*50) -admin = Int (input ("Please enter the function number:")) - the ifadmin = = 1: - whileTrue: -New_name = input ("Please enter your name:") - ifNew_name = ="return": + Break - name.append (new_name) + Print("=======> added successfully! ") A Print("=======> has now been added with the name:%s"%(name)) at Print("=======> return Menu Please enter: Return") - elifadmin = = 2: - whileTrue: -Al_name = input ("Please enter the name you want to change:") - ifAl_name = ="return": - Break in ifAl_nameinchName: -Als_name = input ("Please enter a new name:") to Name.remove (al_name) + name.append (als_name) - Print("=======> 's current name is:%s"%(name)) the Else: * Print("The name you entered does not exist, please re-enter! ") $ Print("=======> return Menu Please enter: Return")Panax Notoginseng elifadmin = = 3: - whileTrue: theDel_name = input ("Please enter the name you want to delete:") + ifDel_name = ="return": A Break the Name.remove (del_name) + Print("=======> Delete Success! ") - Print("=======> currently has the remaining name:%s"%(name)) $ Print("=======> return Menu Please enter: Return") $ elifadmin = = 4: - whileTrue: -Look_name = input ("Please enter the name you want to query:") the ifLook_name = ="return": - BreakWuyi Else: the ifLook_nameinchName: - Print("the name you want to query exists! ") Wu Else: - Print("no such person! ") About Print("=======> return Menu Please enter: Return") $ elifadmin = = 5: -NAME_FL =1 - Else: - Print("your input is wrong, please enter it again! ") A + #===== Login Registration theAD = {} -NAME_FL =0 $ whileNAME_FL = =0: the Print("="*50) the Print("Welcome to use card management system V1.0") the Print("1. Login") the Print("2. Registration") - Print("3. Exit") in Print("="*50) the theadmin_1 = Int (input ("Please enter the function number:")) About the ifAdmin_1 = = 1: the whileTrue: theadmin = input ("Please enter your login account:") +passwd = input ("Please enter your login password:") - forAdmins,passwdsinchAd.items (): the ifadmin = = Admins andpasswd = =Passwds:Bayi Print("Login Successful! ") the Mingpian () the - Else: - Print("incorrect account or password! Please sign in again! ") the elifAdmin_1 = = 2: the whileTrue: theNew_zh = input ("Please enter your registered account:") the ifNew_zhinchAd.keys (): - Print("account already exists! Please enter the new! ") the Else: theNEW_PASSWD = input ("Please enter the registration password:") theAd[new_zh] =new_passwd94 Print("Registration Successful! ") the Break the elifAdmin_1 ==3: the Print("thanks for using the card management system V1.0, Goodbye! ")98 Else: About Print("input Error, please re-enter! ")
Can't jump out of it ....
Python: Business card management system (problems after adding login function, ask for advice)