python實現(xiàn)班級檔案管理系統(tǒng)
本文實例為大家分享了python實現(xiàn)班級檔案管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
功能要求
一、對一個有N個學(xué)生的班級,通過該系統(tǒng)實現(xiàn)對班級學(xué)生的基本信息進(jìn)行錄入、顯示、修改、刪除、保存等操作的管理。
二、 功能要求
1.本系統(tǒng)序列或字典存放數(shù)據(jù),數(shù)據(jù)包括:學(xué)號、姓名、性別、年齡、備注。
2.本系統(tǒng)顯示這樣的菜單:
a.學(xué)生基本信息錄入
b.學(xué)生基本信息顯示
c.學(xué)生基本信息保存
d.學(xué)生基本信息刪除
e.學(xué)生基本信息修改
f.學(xué)生基本信息查詢
(1)按學(xué)號查詢
(2)按性別查詢
(3)按年齡查詢
g.退出系統(tǒng)
3.將學(xué)生基本信息保存到文件中。
4.進(jìn)入系統(tǒng)之前要先輸入密碼
代碼如下
import openpyxl
from openpyxl import Workbook
import sys
s_information = [{'學(xué)號':'202031108041','姓名':'小明','性別':'男','年齡':'20','備注':'帥比'},
? ? ? ? ?{'學(xué)號':'202031108042','姓名':'小谷','性別':'女','年齡':'20','備注':'漂比'},
? ? ? ? ?{'學(xué)號':'202031108043','姓名':'小啊','性別':'男','年齡':'20','備注':'帥比'},
? ? ? ? ?{'學(xué)號':'202031108044','姓名':'小額','性別':'男','年齡':'20','備注':'帥比'},
? ? ? ? ?]
#登錄密碼
def print_menu():
? ? # 打印菜單
? ? print('-'*50)
? ? print('[1]:學(xué)生基本信息錄入')
? ? print('[2]:學(xué)生基本信息顯示')
? ? print('[3]:學(xué)生基本信息保存')
? ? print('[4]:學(xué)生基本信息刪除')
? ? print('[5]:學(xué)生基本信息修改')
? ? print('[6]:學(xué)生基本信息查詢')
? ? print('[7]:退出')
#基本信息錄入
def add_infomation():
? ? dic = {}
? ? while True:
? ? ? ? xuehao = input('請輸入你的學(xué)號:')
? ? ? ? for i in s_information:
? ? ? ? ? ? if i['學(xué)號'] == xuehao:
? ? ? ? ? ? ? ? print('學(xué)號已存在,請重新輸入')
? ? ? ? else:
? ? ? ? ? ? dic['學(xué)號'] = xuehao
? ? ? ? ? ? dic['姓名'] = input('請輸入姓名:')
? ? ? ? ? ? dic['性別'] = input('請輸入性別:')
? ? ? ? ? ? dic['年齡'] = input('請輸入年齡:')
? ? ? ? ? ? dic['備注'] = input('請輸入備注:')
? ? ? ? ? ? break
? ? s_information.append(dic)
#顯示所有信息
def show_information():
? ? for i in s_information:
? ? ? ? print(i)
#刪除學(xué)生信息,可以添加學(xué)生信息不在時的情況
def del_information():
? ? a = input('請輸入你要刪除的學(xué)生的姓名:')
? ? for i in s_information:
? ? ? ? if a == i['姓名']:
? ? ? ? ? ? s_information.remove(i)
#學(xué)生基本信息修改:
def change_information():
? ? a = input('請輸入你要修改人的信息,如姓名、電話')
? ? print('1、學(xué)號')
? ? print('2、姓名')
? ? print('3、性別')
? ? print('4、年齡')
? ? print('5、備注')
? ? b = input('請輸入你要修改的選項:')
? ? for i in s_information:
? ? ? ? if i['姓名'] == a :
? ? ? ? ? ? if b=="1":
? ? ? ? ? ? ? ? i['學(xué)號']=input('請輸入修改后的:')
? ? ? ? ? ? elif b=='2':
? ? ? ? ? ? ? ? i['姓名']=input('請輸入修改后的:')
? ? ? ? ? ? elif b=='3':
? ? ? ? ? ? ? ? i['性別'] = input('請輸入修改后的:')
? ? ? ? ? ? elif b=='4':
? ? ? ? ? ? ? ? i['年齡'] = input('請輸入修改后的:')
? ? ? ? ? ? else:
? ? ? ? ? ? ? ? i['備注']= input('請輸入修改后的:')
? ? ? ? ? ? break
? ? ? ? elif i['學(xué)號'] == a :
? ? ? ? ? ? if b=="1":
? ? ? ? ? ? ? ? i['學(xué)號']=input('請輸入修改后的:')
? ? ? ? ? ? elif b=='2':
? ? ? ? ? ? ? ? i['姓名']=input('請輸入修改后的:')
? ? ? ? ? ? elif b=='3':
? ? ? ? ? ? ? ? i['性別'] = input('請輸入修改后的:')
? ? ? ? ? ? elif b=='4':
? ? ? ? ? ? ? ? i['年齡'] = input('請輸入修改后的:')
? ? ? ? ? ? else:
? ? ? ? ? ? ? ? i['備注']= input('請輸入修改后的:')
? ? ? ? ? ? break
? ? ? ? else:
? ? ? ? ? ? print('請輸入學(xué)號、或姓名進(jìn)行查詢')
#學(xué)生基本信息查詢
def select_information():
? ? a = input('請輸入你要查詢?nèi)说男彰驅(qū)W號')
? ? for i in s_information:
? ? ? ? if i['姓名'] ?== a:
? ? ? ? ? ? print(i)
? ? ? ? ? ? break
? ? ? ? elif i['學(xué)號'] == a :
? ? ? ? ? ? print(i)
? ? ? ? ? ? break
? ? ? ? else:
? ? ? ? ? ? print(''請輸入學(xué)號或者姓名進(jìn)行查詢')
#學(xué)生信息保存
def write_tofile():
? ? a = input('請輸入你要保存文件的名稱:')
? ? wb=Workbook()
? ? sheet1 = wb.create_sheet('學(xué)生信息表',0)
? ? sheet1.cell(row=1,column=1).value='學(xué)號'
? ? sheet1.cell(row=1,column=2).value='姓名'
? ? sheet1.cell(row=1,column=3).value='性別'
? ? sheet1.cell(row=1,column=4).value='年齡'
? ? sheet1.cell(row=1,column=5).value='備注'
? ? for i in range(len(s_information)):
? ? ? ?
? ? ? ??
? ? ? ??
? ? ? ? sheet1.cell(row=i+2,column=1).value=s_information[i]['學(xué)號']
? ? ? ? sheet1.cell(row=i+2,column=2).value=s_information[i]['姓名']
? ? ? ? sheet1.cell(row=i+2,column=3).value=s_information[i]['性別']
? ? ? ? sheet1.cell(row=i+2,column=4).value=s_information[i]['年齡']
? ? ? ? sheet1.cell(row=i+2,column=5).value=s_information[i]['備注']
? ? ? ??
? ? wb.save('{}.xlsx'.format(a))
#離開程序 ? ?
def quit_information():
? ? sys.exit(0) ? ? ??
#設(shè)置主函數(shù)
def main2():
? ? ? while True:#設(shè)置登錄密碼
? ? ? ? ? ? print('------登陸-------')
? ? ? ? ? ? print('賬號是學(xué)號,密碼是學(xué)號后五位')
? ? ? ? ? ? key_word = input("賬號:")
? ? ? ? ? ? password = input("密碼:")
? ? ? ? ? ? while True and password == ?key_word[-5:] and len(key_word) > 5:
? ? ? ? ? ? ? ? print('------班級管理系統(tǒng)------')
? ? ? ? ? ?
? ? ? ? ? ? ? ? print_menu() ? ?# 打印菜單
? ? ? ? ? ? ? ? num = input('請輸入您的選項:')
? ? ? ? ? ? ? ? if num == '1':
? ? ? ? ? ? ? ? ? ? add_infomation() ?# 添加圖書
? ? ? ? ? ? ? ? elif num == '2':
? ? ? ? ? ? ? ? ? ? show_information() ?# 刪除圖書
? ? ? ? ? ? ? ? elif num == '3':
? ? ? ? ? ? ? ? ? ? write_tofile() # 查詢所有圖書
? ? ? ? ? ? ? ? elif num == '4':
? ? ? ? ? ? ? ? ? ? del_information()
? ? ? ? ? ? ? ? elif num == '5':
? ? ? ? ? ? ? ? ? ? change_information()
? ? ? ? ? ? ? ? elif num == '6':
? ? ? ? ? ? ? ? ? ? select_information()
? ? ? ? ? ? ? ? elif num == '7':
? ? ? ? ? ? ? ? ? ? quit_information()
? ? ? ? ? ? ? ? else:
? ? ? ? ? ? ? ? ? ? print('您選擇的有誤,請重新選擇')
? ? ? ? ? ? else:
? ? ? ? ? ? ? ? print('你輸入的密碼有誤,請重新輸入')
if __name__ == '__main__':
? ? main2()
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- python學(xué)生信息管理系統(tǒng)(完整版)
- Python實現(xiàn)GUI學(xué)生信息管理系統(tǒng)
- python實現(xiàn)學(xué)生信息管理系統(tǒng)
- python實現(xiàn)簡易學(xué)生信息管理系統(tǒng)
- Python學(xué)生成績管理系統(tǒng)簡潔版
- python學(xué)生管理系統(tǒng)代碼實現(xiàn)
- python學(xué)生信息管理系統(tǒng)
- Python基于mysql實現(xiàn)學(xué)生管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)實現(xiàn)代碼
- python學(xué)生信息管理系統(tǒng)(初級版)
相關(guān)文章
Django ORM多對多查詢方法(自定義第三張表&ManyToManyField)
今天小編就為大家分享一篇Django ORM多對多查詢方法(自定義第三張表&ManyToManyField),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-08-08
對python操作kafka寫入json數(shù)據(jù)的簡單demo分享
今天小編就為大家分享一篇對python操作kafka寫入json數(shù)據(jù)的簡單demo,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-12-12
Python抓取聚劃算商品分析頁面獲取商品信息并以XML格式保存到本地
這篇文章主要為大家詳細(xì)介紹了Python抓取聚劃算商品分析頁面獲取商品信息,并以XML格式保存到本地的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-02-02
Python辦公自動化之自動化清理數(shù)據(jù)和自動化系統(tǒng)命令詳解
這篇文章主要為大家詳細(xì)介紹了Python辦公自動化中自動化清理數(shù)據(jù)和自動化系統(tǒng)命令的相關(guān)知識,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解下2024-01-01
Python調(diào)用edge-tts實現(xiàn)在線文字轉(zhuǎn)語音效果
edge-tts是一個 Python 模塊,允許通過Python代碼或命令的方式使用 Microsoft Edge 的在線文本轉(zhuǎn)語音服務(wù),這篇文章主要介紹了Python調(diào)用edge-tts實現(xiàn)在線文字轉(zhuǎn)語音效果,需要的朋友可以參考下2024-03-03
python合并RepeatMasker預(yù)測結(jié)果中染色體的overlap區(qū)域
這篇文章主要為大家介紹了python合并RepeatMasker預(yù)測結(jié)果中染色體的overlap區(qū)域?qū)崿F(xiàn)示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07
Python利用前序和中序遍歷結(jié)果重建二叉樹的方法
這篇文章主要介紹了Python利用前序和中序遍歷結(jié)果重建二叉樹的方法,實例分析了Python二叉樹的定義與遍歷操作技巧,需要的朋友可以參考下2016-04-04

