class Student: def register(self): print("=============註冊頁面=============") n = 3 user = input("請輸入帳號:").strip() while n > 0: n = n -1 pass_wd = input("請輸入密碼:").strip() pass_wd_sec = input("確認你的密碼:").strip() if pass_wd != pass_wd_sec: print("兩次輸入不一致,請從新輸入!\n") print("你還有" + str(n) + "次機會!") continue else: print("註冊成功!\n") user_info[user] = pass_wd_sec break def login(self): n = 3 while n > 0: n = n - 1 pass_wd = input("請輸入你的密碼:").strip() if pass_wd != user_info[user]: print("密碼錯誤,請從新輸入!\n") print("你還有" + str(n) + "次機會!") continue else: print("登陸成功!\n") break def achievement(self): # 這裏實現成績錄入與成績查詢 print("請錄入你的成績!") while True: subject_name = input("課程名稱:") score = int(input("課程分數")) student_score[subject_name] = score status = input("\n選擇你的操做 【0:繼續,1:查看,其餘:退出】") if status == '0': continue elif status == '1': choice = input("請輸入你要查看的課程名稱:【1:所有,其餘:當前】") if choice == '1': print(student_score) else: print(student_score[choice]) else: break def course_selection(self): all_course = ['java', 'hadoop'] my_course = [] while True: print("\n你當前的課程有:" + str(my_course)) print("\n當前可選的課程有:" + str(all_course)) course_name = input("請輸入你要選擇的課程:") my_course.append(course_name) print("選課結果爲:" + str(my_course)) break if __name__ == '__main__': user_info = {"hadoop": "111", "hive": "222", "spark": "333"} student_score = {"語文": 86, "數學": 96, "英語": 81, "化學": 91, "物理": 92} user = input("請輸入帳號:").strip() s = Student() if user not in user_info.keys(): print("帳號不存在,請返回註冊\n") s.register() print("=============登陸界面=============") user = input("請輸入帳號:").strip() s.login() s.achievement() else: s.login() s.achievement() s.course_selection()