python學(xué)生信息管理系統(tǒng)實(shí)現(xiàn)代碼
1.本人第一次學(xué)python做出來的,當(dāng)時(shí)滿滿的成就感,當(dāng)作紀(jì)念?。。。?!
非常簡單,復(fù)制即可使用
代碼塊
import json#把字符串類型的數(shù)據(jù)轉(zhuǎn)換成Python基本數(shù)據(jù)類型或者將Python基本數(shù)據(jù)類型轉(zhuǎn)換成字符串類型。 def login_user(): while True: register=input('學(xué)生姓名:') try: with open(register+'.json')as file_object: user_message=json.load(file_object)#json.load(obj) 讀取文件中的字符串,序列化成Python的基本數(shù)據(jù)類型 except FileNotFoundError: print('該用戶不存在!') break else: print('_'*20) register_password = input('請輸入學(xué)號:') if user_message['id']==register and user_message['password']==register_password: str_print = '姓名:{}\t數(shù)學(xué)成績:{}\t語文成績:{}\t英語成績: {}' grade_list = [] while 1: print('''****************************** 歡迎使用【學(xué)生信息管理系統(tǒng)】 請選擇你想要進(jìn)行的操作 1.新建學(xué)生信息 2.顯示全部信息 3.查詢學(xué)生信息 4.刪除學(xué)生信息 5.修改學(xué)生信息 0.退出系統(tǒng) ******************************''') action = input('請選擇你想要的進(jìn)行操作:\n') if action == '1': '''新建學(xué)生信息''' name = input('請輸入名字') math = input('請輸入數(shù)學(xué)成績') chinese = input('請輸入語文成績') english = input('請輸入英語成績') total = int(math) + int(chinese) + int(english) grade_list.append([name,math,chinese,english,total]) print([name,math,chinese,english,total]) print('姓名:{}\t數(shù)學(xué)成績:{}\t語文成績:{}\t英語成績: {}'.format(name,math,chinese,english,total)) pass elif action == '2': '''顯示全部信息''' for info in grade_list: print(str_print.format(*info)) elif action == '3': '''查詢學(xué)生信息''' name = input('請輸入你需要查詢學(xué)生的姓名:') for info in grade_list: if name in info: print(str_print.format(*info)) break else: print('此學(xué)生不存在') elif action == '4': '''刪除學(xué)生信息''' name = input('請輸入你需要查詢學(xué)生的姓名:') for info in grade_list: if name in info: info_=grade_list.pop(grade_list.index(info)) print('這個(gè)學(xué)員的信息已經(jīng)被刪除\n',info_) break else: print('此學(xué)生不存在') elif action == '5': '''修改學(xué)生信息''' name = input('請輸入你需要查詢學(xué)生的姓名:') for info in grade_list: if name in info: index = grade_list.index(info) break else: print('此學(xué)生不存在') continue math = input('請輸入數(shù)學(xué)成績:') chinese = input('請輸入語文成績:') english = input('請輸入英語成績:') total = int(math) + int(chinese) + int(english) grade_list[index][0:] = [name,math,chinese,english,total] print('修改后的一個(gè)成績',grade_list[index]) elif action == '0': '''退出系統(tǒng)''' break else: print('輸入信息有誤,請重新輸入') #print('登陸成功') return register,user_message else: print('登陸失??!用戶名或密碼錯(cuò)誤') break def register_user(): new_user=input('增加學(xué)生姓名:') try: with open(new_user+',.jion','r') as file_object: pass except FileNotFoundError: new_password_one=input('請確認(rèn)學(xué)號:') new_password_two=input('請?jiān)俅未_認(rèn)學(xué)號:') if new_password_one==new_password_two: user_message={'id':new_user,'password':new_password_one} with open(new_user+'.json','w')as file_object: json.dump(user_message,file_object)#json.dump(obj) 將Python的基本數(shù)據(jù)類型序列化成字符串并寫入到文件中 print('新用戶已經(jīng)注冊成功!可以登錄了。') else: print('兩次輸入不一致') else: print('該用戶已經(jīng)存在') while True: print('*'*50) print('* 1.登錄用戶 *') print('* *') print('* 2.注冊用戶 *') print('* *') print('* 3.退出 *') print('*'*50) test_content=input('請輸入你的選項(xiàng):') if test_content=='1': try: user_id,user_system=login_user() pass except TypeError: print('請重新輸入') # print('登錄用戶!') elif test_content=='2': register_user() #print('注冊用戶') elif test_content=='3': print('退出系統(tǒng)') break else: print('非法輸入字符')
效果圖(里面的全部功能都可以實(shí)現(xiàn))
總結(jié)
以上所述是小編給大家介紹的python學(xué)生信息管理系統(tǒng)實(shí)現(xiàn)代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
- python學(xué)生信息管理系統(tǒng)(完整版)
- Python實(shí)現(xiàn)GUI學(xué)生信息管理系統(tǒng)
- python實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- python實(shí)現(xiàn)簡易學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)
- python實(shí)現(xiàn)簡單學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)(初級版)
- python學(xué)生信息管理系統(tǒng)實(shí)現(xiàn)代碼
- python代碼實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- Python結(jié)合MySQL數(shù)據(jù)庫編寫簡單信息管理系統(tǒng)完整實(shí)例
相關(guān)文章
Python實(shí)戰(zhàn)之手寫一個(gè)搜索引擎
這篇文章主要介紹了Python實(shí)戰(zhàn)之手寫一個(gè)搜索引擎,文中有非常詳細(xì)的代碼示例,對正在學(xué)習(xí)python的小伙伴們有非常好的幫助,需要的朋友可以參考下2021-04-04Python數(shù)據(jù)分析matplotlib折線圖案例處理
這篇文章主要介紹了Python數(shù)據(jù)分析matplotlib折線圖案例處理,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-08-08Python實(shí)例之wxpython中Frame使用方法
本文介紹下wxpython中Frame的用法,不錯(cuò)的python編程實(shí)例,有需要的朋友參考下2014-06-06Python實(shí)現(xiàn)的KMeans聚類算法實(shí)例分析
這篇文章主要介紹了Python實(shí)現(xiàn)的KMeans聚類算法,結(jié)合實(shí)例形式較為詳細(xì)的分析了KMeans聚類算法概念、原理、定義及使用相關(guān)操作技巧,需要的朋友可以參考下2018-12-12python自動化腳本安裝指定版本python環(huán)境詳解
這篇文章主要為大家詳細(xì)介紹了python自動化腳本安裝指定版本python環(huán)境的相關(guān)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09Python實(shí)現(xiàn)將內(nèi)容寫入文件的五種方法總結(jié)
本篇帶你詳細(xì)看一下python將內(nèi)容寫入文件的方法以及細(xì)節(jié),主要包括write()方法、writelines()?方法、print()?函數(shù)、使用?csv?模塊、使用?json?模塊,需要的可以參考一下2023-04-04Python實(shí)現(xiàn)圖像和辦公文檔處理的方法和技巧
本文介紹了Python實(shí)現(xiàn)圖像和辦公文檔處理的方法和技巧,包括使用Pillow庫處理圖像、使用OpenCV庫進(jìn)行圖像識別和處理、使用PyPDF2庫處理PDF文檔、使用docx和xlwt庫處理Word和Excel文檔等,幫助讀者更好地掌握Python在圖像和辦公文檔處理方面的應(yīng)用2023-05-05django框架實(shí)現(xiàn)模板中獲取request 的各種信息示例
這篇文章主要介紹了django框架實(shí)現(xiàn)模板中獲取request 的各種信息,結(jié)合實(shí)例形式分析了Django框架模板直接獲取request信息的相關(guān)配置與操作技巧,需要的朋友可以參考下2019-07-07