學(xué)生信息管理系統(tǒng)Python面向?qū)ο蟀?/h1>
更新時(shí)間:2019年01月30日 15:17:44 作者:青衣煮茶
這篇文章主要為大家詳細(xì)介紹了學(xué)生信息管理系統(tǒng)Python面向?qū)ο蟀?,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了python學(xué)生信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
"""
程序名稱:學(xué)生信息管理系統(tǒng)
版本信息:0.1
開發(fā)者:飛宇
開始時(shí)間:2018.3.23 19:45
版本更新時(shí)間:2018.4.2 23:08
格式:IPO
OOP面向?qū)ο?
"""
# 學(xué)生類
class Student:
def __init__(self, stuId, name, age, sex, dept, nation):
self.stuId = stuId
self.name = name
self.age = age
self.sex = sex
self.dept = dept
self.nation = nation
def studentoop(self):
pass
# 管理系統(tǒng)類
class Sys:
def __init__(self):
pass
# 展示系統(tǒng)菜單
def show_menu(self):
print("=" * 56)
print("")
print(" 學(xué)生信息管理系統(tǒng) v1.0")
print("")
print(" 1:添加用戶信息")
print(" 2:查詢用戶信息")
print(" 3:修改用戶信息")
print(" 4:刪除用戶信息")
print(" 5:顯示用戶信息")
print(" 0:退出系統(tǒng)")
print("")
print("=" * 56)
# 輸入學(xué)生菜單
def getinfo(self):
global new_stuId
global new_name
global new_age
global new_sex
global new_dept
global new_nation
new_stuId = input("請輸入學(xué)號:")
new_name = input("請輸入名字:")
new_age = input("請輸入年齡:")
new_sex = input("請輸入性別:")
new_dept = input("請輸入專業(yè):")
new_nation = input("請輸入民族:")
# 添加學(xué)生信息
def add_stus(self):
#調(diào)用getinfo方法
self.getinfo()
#以ID為Key,將新輸入的信息賦值給Student類
students[new_stuId] = Student(new_stuId, new_name, new_age, new_sex, new_dept, new_nation)
# 打印添加的學(xué)生信息
print("學(xué)號:%s" % students[new_stuId].stuId, "姓名:%s" % students[new_stuId].name, "年齡:%s" % students[new_stuId].age,
"性別:%s" % students[new_stuId].sex, "專業(yè):%s" % students[new_stuId].dept, "民族:%s" % students[new_stuId].nation)
print("=" * 56)
# 查詢學(xué)生信息
def find_stus(self):
find_nameId = input("請輸入要查的學(xué)號")
if find_nameId in students.keys():
print("學(xué)號:%s\t名字:%s\t年齡:%s\t性別:%s\t名字:%s\t民族:%s" %
(students[new_stuId].stuId, students[new_stuId].name, students[new_stuId].age,
students[new_stuId].sex, students[new_stuId].dept, students[new_stuId].nation))
else:
print("查無此人")
print("=" * 56)
# 修改學(xué)生信息
def alter_stus(self):
alterId = input("請輸入你要修改學(xué)生的學(xué)號:")
self.getinfo()
# 當(dāng)字典中Key相同時(shí),覆蓋掉以前的key值
if alterId in students.keys():
students[new_stuId] = Student(new_stuId, new_name, new_age, new_sex, new_dept, new_nation)
del students[alterId]
else:
print("查無此人")
print("=" * 56)
# 刪除學(xué)生信息
def del_stus(self):
cut_nameID = input("請輸入要刪除的學(xué)號:")
if cut_nameID in students.keys():
del students[cut_nameID]
else:
print("查無此人")
print("=" * 56)
# 顯示學(xué)生信息
def show_stus(self):
for new_stuId in students:
print("學(xué)號:%s\t名字:%s\t年齡:%s\t性別:%s\t名字:%s\t民族:%s" %
(students[new_stuId].stuId, students[new_stuId].name, students[new_stuId].age,
students[new_stuId].sex, students[new_stuId].dept, students[new_stuId].nation))
print("=" * 56)
# 退出
def exit_stus(self):
print("歡迎下次使用")
exit()
# 創(chuàng)建系統(tǒng)對象
sys = Sys()
# 定義一個容器來存儲學(xué)生信息
students = {}
sys.show_menu()
while True:
choice = int(input("請選擇功能:"))
if choice == 1:
sys.add_stus()
elif choice == 2:
sys.find_stus()
elif choice == 3:
sys.alter_stus()
elif choice == 4:
sys.del_stus()
elif choice == 5:
sys.show_stus()
elif choice == 0:
sys.exit_stus()
else:
print("您輸入有誤,請重新輸入")
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:- 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實(shí)現(xiàn)外賣信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)實(shí)現(xiàn)代碼
- python實(shí)現(xiàn)簡單學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)(初級版)
- python實(shí)現(xiàn)簡易的學(xué)生信息管理系統(tǒng)
相關(guān)文章
-
對python3 sort sorted 函數(shù)的應(yīng)用詳解
今天小編就為大家分享一篇對python3 sort sorted 函數(shù)的應(yīng)用詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧 2019-06-06
-
Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(luò)(CNN)實(shí)現(xiàn)MNIST數(shù)據(jù)集分類任務(wù)
這篇文章主要介紹了Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(luò)(CNN)實(shí)現(xiàn)MNIST數(shù)據(jù)集分類任務(wù),本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下 2023-03-03
-
對Python函數(shù)設(shè)計(jì)規(guī)范詳解
今天小編就為大家分享一篇對Python函數(shù)設(shè)計(jì)規(guī)范詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧 2019-07-07
-
python itchat實(shí)現(xiàn)微信自動回復(fù)的示例代碼
本篇文章主要介紹了python itchat實(shí)現(xiàn)微信自動回復(fù)的示例代碼,可以實(shí)現(xiàn)微信自動回復(fù),有興趣的可以了解一下
2017-08-08
-
Python?Pandas學(xué)習(xí)之series的二元運(yùn)算詳解
二元運(yùn)算是指由兩個元素形成第三個元素的一種規(guī)則,例如數(shù)的加法及乘法;更一般地,由兩個集合形成第三個集合的產(chǎn)生方法或構(gòu)成規(guī)則稱為二次運(yùn)算。本文將詳細(xì)講講Pandas中series的二元運(yùn)算,感興趣的可以了解一下 2022-09-09
-
詳解如何修改jupyter notebook的默認(rèn)目錄和默認(rèn)瀏覽器
這篇文章主要介紹了詳解如何修改jupyter notebook的默認(rèn)目錄和默認(rèn)瀏覽器,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧 2021-01-01
-
使用Numpy對特征中的異常值進(jìn)行替換及條件替換方式
這篇文章主要介紹了使用Numpy對特征中的異常值進(jìn)行替換及條件替換方式,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧 2020-06-06
-
python網(wǎng)絡(luò)爬蟲采集聯(lián)想詞示例
這篇文章主要介紹了python網(wǎng)絡(luò)爬蟲采集聯(lián)想詞示例,需要的朋友可以參考下 2014-02-02
最新評論
本文實(shí)例為大家分享了python學(xué)生信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
""" 程序名稱:學(xué)生信息管理系統(tǒng) 版本信息:0.1 開發(fā)者:飛宇 開始時(shí)間:2018.3.23 19:45 版本更新時(shí)間:2018.4.2 23:08 格式:IPO OOP面向?qū)ο? """ # 學(xué)生類 class Student: def __init__(self, stuId, name, age, sex, dept, nation): self.stuId = stuId self.name = name self.age = age self.sex = sex self.dept = dept self.nation = nation def studentoop(self): pass # 管理系統(tǒng)類 class Sys: def __init__(self): pass # 展示系統(tǒng)菜單 def show_menu(self): print("=" * 56) print("") print(" 學(xué)生信息管理系統(tǒng) v1.0") print("") print(" 1:添加用戶信息") print(" 2:查詢用戶信息") print(" 3:修改用戶信息") print(" 4:刪除用戶信息") print(" 5:顯示用戶信息") print(" 0:退出系統(tǒng)") print("") print("=" * 56) # 輸入學(xué)生菜單 def getinfo(self): global new_stuId global new_name global new_age global new_sex global new_dept global new_nation new_stuId = input("請輸入學(xué)號:") new_name = input("請輸入名字:") new_age = input("請輸入年齡:") new_sex = input("請輸入性別:") new_dept = input("請輸入專業(yè):") new_nation = input("請輸入民族:") # 添加學(xué)生信息 def add_stus(self): #調(diào)用getinfo方法 self.getinfo() #以ID為Key,將新輸入的信息賦值給Student類 students[new_stuId] = Student(new_stuId, new_name, new_age, new_sex, new_dept, new_nation) # 打印添加的學(xué)生信息 print("學(xué)號:%s" % students[new_stuId].stuId, "姓名:%s" % students[new_stuId].name, "年齡:%s" % students[new_stuId].age, "性別:%s" % students[new_stuId].sex, "專業(yè):%s" % students[new_stuId].dept, "民族:%s" % students[new_stuId].nation) print("=" * 56) # 查詢學(xué)生信息 def find_stus(self): find_nameId = input("請輸入要查的學(xué)號") if find_nameId in students.keys(): print("學(xué)號:%s\t名字:%s\t年齡:%s\t性別:%s\t名字:%s\t民族:%s" % (students[new_stuId].stuId, students[new_stuId].name, students[new_stuId].age, students[new_stuId].sex, students[new_stuId].dept, students[new_stuId].nation)) else: print("查無此人") print("=" * 56) # 修改學(xué)生信息 def alter_stus(self): alterId = input("請輸入你要修改學(xué)生的學(xué)號:") self.getinfo() # 當(dāng)字典中Key相同時(shí),覆蓋掉以前的key值 if alterId in students.keys(): students[new_stuId] = Student(new_stuId, new_name, new_age, new_sex, new_dept, new_nation) del students[alterId] else: print("查無此人") print("=" * 56) # 刪除學(xué)生信息 def del_stus(self): cut_nameID = input("請輸入要刪除的學(xué)號:") if cut_nameID in students.keys(): del students[cut_nameID] else: print("查無此人") print("=" * 56) # 顯示學(xué)生信息 def show_stus(self): for new_stuId in students: print("學(xué)號:%s\t名字:%s\t年齡:%s\t性別:%s\t名字:%s\t民族:%s" % (students[new_stuId].stuId, students[new_stuId].name, students[new_stuId].age, students[new_stuId].sex, students[new_stuId].dept, students[new_stuId].nation)) print("=" * 56) # 退出 def exit_stus(self): print("歡迎下次使用") exit() # 創(chuàng)建系統(tǒng)對象 sys = Sys() # 定義一個容器來存儲學(xué)生信息 students = {} sys.show_menu() while True: choice = int(input("請選擇功能:")) if choice == 1: sys.add_stus() elif choice == 2: sys.find_stus() elif choice == 3: sys.alter_stus() elif choice == 4: sys.del_stus() elif choice == 5: sys.show_stus() elif choice == 0: sys.exit_stus() else: print("您輸入有誤,請重新輸入")
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 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實(shí)現(xiàn)外賣信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)實(shí)現(xiàn)代碼
- python實(shí)現(xiàn)簡單學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)(初級版)
- python實(shí)現(xiàn)簡易的學(xué)生信息管理系統(tǒng)
相關(guān)文章
對python3 sort sorted 函數(shù)的應(yīng)用詳解
今天小編就為大家分享一篇對python3 sort sorted 函數(shù)的應(yīng)用詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(luò)(CNN)實(shí)現(xiàn)MNIST數(shù)據(jù)集分類任務(wù)
這篇文章主要介紹了Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(luò)(CNN)實(shí)現(xiàn)MNIST數(shù)據(jù)集分類任務(wù),本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03對Python函數(shù)設(shè)計(jì)規(guī)范詳解
今天小編就為大家分享一篇對Python函數(shù)設(shè)計(jì)規(guī)范詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-07-07python itchat實(shí)現(xiàn)微信自動回復(fù)的示例代碼
本篇文章主要介紹了python itchat實(shí)現(xiàn)微信自動回復(fù)的示例代碼,可以實(shí)現(xiàn)微信自動回復(fù),有興趣的可以了解一下2017-08-08Python?Pandas學(xué)習(xí)之series的二元運(yùn)算詳解
二元運(yùn)算是指由兩個元素形成第三個元素的一種規(guī)則,例如數(shù)的加法及乘法;更一般地,由兩個集合形成第三個集合的產(chǎn)生方法或構(gòu)成規(guī)則稱為二次運(yùn)算。本文將詳細(xì)講講Pandas中series的二元運(yùn)算,感興趣的可以了解一下2022-09-09詳解如何修改jupyter notebook的默認(rèn)目錄和默認(rèn)瀏覽器
這篇文章主要介紹了詳解如何修改jupyter notebook的默認(rèn)目錄和默認(rèn)瀏覽器,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01使用Numpy對特征中的異常值進(jìn)行替換及條件替換方式
這篇文章主要介紹了使用Numpy對特征中的異常值進(jìn)行替換及條件替換方式,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-06-06python網(wǎng)絡(luò)爬蟲采集聯(lián)想詞示例
這篇文章主要介紹了python網(wǎng)絡(luò)爬蟲采集聯(lián)想詞示例,需要的朋友可以參考下2014-02-02