學生信息管理系統(tǒng)Python面向?qū)ο蟀?/h1>
更新時間:2019年01月30日 15:17:44 作者:青衣煮茶
這篇文章主要為大家詳細介紹了學生信息管理系統(tǒng)Python面向?qū)ο蟀?,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了python學生信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
"""
程序名稱:學生信息管理系統(tǒng)
版本信息:0.1
開發(fā)者:飛宇
開始時間:2018.3.23 19:45
版本更新時間:2018.4.2 23:08
格式:IPO
OOP面向?qū)ο?
"""
# 學生類
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(" 學生信息管理系統(tǒng) v1.0")
print("")
print(" 1:添加用戶信息")
print(" 2:查詢用戶信息")
print(" 3:修改用戶信息")
print(" 4:刪除用戶信息")
print(" 5:顯示用戶信息")
print(" 0:退出系統(tǒng)")
print("")
print("=" * 56)
# 輸入學生菜單
def getinfo(self):
global new_stuId
global new_name
global new_age
global new_sex
global new_dept
global new_nation
new_stuId = input("請輸入學號:")
new_name = input("請輸入名字:")
new_age = input("請輸入年齡:")
new_sex = input("請輸入性別:")
new_dept = input("請輸入專業(yè):")
new_nation = input("請輸入民族:")
# 添加學生信息
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)
# 打印添加的學生信息
print("學號:%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)
# 查詢學生信息
def find_stus(self):
find_nameId = input("請輸入要查的學號")
if find_nameId in students.keys():
print("學號:%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)
# 修改學生信息
def alter_stus(self):
alterId = input("請輸入你要修改學生的學號:")
self.getinfo()
# 當字典中Key相同時,覆蓋掉以前的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)
# 刪除學生信息
def del_stus(self):
cut_nameID = input("請輸入要刪除的學號:")
if cut_nameID in students.keys():
del students[cut_nameID]
else:
print("查無此人")
print("=" * 56)
# 顯示學生信息
def show_stus(self):
for new_stuId in students:
print("學號:%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()
# 定義一個容器來存儲學生信息
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)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
-
對python3 sort sorted 函數(shù)的應用詳解
今天小編就為大家分享一篇對python3 sort sorted 函數(shù)的應用詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧 2019-06-06
-
Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(CNN)實現(xiàn)MNIST數(shù)據(jù)集分類任務
這篇文章主要介紹了Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(CNN)實現(xiàn)MNIST數(shù)據(jù)集分類任務,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下 2023-03-03
-
python itchat實現(xiàn)微信自動回復的示例代碼
本篇文章主要介紹了python itchat實現(xiàn)微信自動回復的示例代碼,可以實現(xiàn)微信自動回復,有興趣的可以了解一下
2017-08-08
-
詳解如何修改jupyter notebook的默認目錄和默認瀏覽器
這篇文章主要介紹了詳解如何修改jupyter notebook的默認目錄和默認瀏覽器,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧 2021-01-01
最新評論
本文實例為大家分享了python學生信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
""" 程序名稱:學生信息管理系統(tǒng) 版本信息:0.1 開發(fā)者:飛宇 開始時間:2018.3.23 19:45 版本更新時間:2018.4.2 23:08 格式:IPO OOP面向?qū)ο? """ # 學生類 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(" 學生信息管理系統(tǒng) v1.0") print("") print(" 1:添加用戶信息") print(" 2:查詢用戶信息") print(" 3:修改用戶信息") print(" 4:刪除用戶信息") print(" 5:顯示用戶信息") print(" 0:退出系統(tǒng)") print("") print("=" * 56) # 輸入學生菜單 def getinfo(self): global new_stuId global new_name global new_age global new_sex global new_dept global new_nation new_stuId = input("請輸入學號:") new_name = input("請輸入名字:") new_age = input("請輸入年齡:") new_sex = input("請輸入性別:") new_dept = input("請輸入專業(yè):") new_nation = input("請輸入民族:") # 添加學生信息 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) # 打印添加的學生信息 print("學號:%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) # 查詢學生信息 def find_stus(self): find_nameId = input("請輸入要查的學號") if find_nameId in students.keys(): print("學號:%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) # 修改學生信息 def alter_stus(self): alterId = input("請輸入你要修改學生的學號:") self.getinfo() # 當字典中Key相同時,覆蓋掉以前的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) # 刪除學生信息 def del_stus(self): cut_nameID = input("請輸入要刪除的學號:") if cut_nameID in students.keys(): del students[cut_nameID] else: print("查無此人") print("=" * 56) # 顯示學生信息 def show_stus(self): for new_stuId in students: print("學號:%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() # 定義一個容器來存儲學生信息 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)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
對python3 sort sorted 函數(shù)的應用詳解
今天小編就為大家分享一篇對python3 sort sorted 函數(shù)的應用詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(CNN)實現(xiàn)MNIST數(shù)據(jù)集分類任務
這篇文章主要介紹了Pytorch搭建簡單的卷積神經(jīng)網(wǎng)絡(CNN)實現(xiàn)MNIST數(shù)據(jù)集分類任務,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-03-03python itchat實現(xiàn)微信自動回復的示例代碼
本篇文章主要介紹了python itchat實現(xiàn)微信自動回復的示例代碼,可以實現(xiàn)微信自動回復,有興趣的可以了解一下2017-08-08詳解如何修改jupyter notebook的默認目錄和默認瀏覽器
這篇文章主要介紹了詳解如何修改jupyter notebook的默認目錄和默認瀏覽器,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-01-01