欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python學(xué)生管理系統(tǒng)學(xué)習(xí)筆記

 更新時間:2019年03月19日 11:16:31   作者:qd_tudou  
這篇文章主要為大家詳細介紹了python學(xué)生管理系統(tǒng)的學(xué)習(xí)筆記,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了python學(xué)生管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

基于列表存儲的學(xué)生管理系統(tǒng),實現(xiàn)如下功能

==================
學(xué)生管理系統(tǒng)
1、添加學(xué)生信息
2、刪除學(xué)生信息
3、查詢學(xué)生信息
4、修改學(xué)生信息
5、顯示所有學(xué)生信息
6、退出
==================

代碼如下:

import re
student=[]
 
def appendStudentInfo():
 studentinfo={"Name":"","ID":"","語文":"","數(shù)學(xué)":"","英語":"","總分":""}
 studentinfo["Name"]=input("請輸入學(xué)生姓名:")
 idflag=True
 while idflag:
  studentinfo["ID"] = input("請輸入學(xué)生學(xué)號:")
  pattern=re.compile("^\d{3}$")
  if not re.match(pattern,studentinfo["ID"]) :
   print("輸入錯誤,請重新輸入")
   idflag = True
  if querystudent(studentinfo["ID"])==True:
   print("該學(xué)號已經(jīng)存在請重新輸入")
   idflag = True
  if querystudent(studentinfo["ID"])==False and re.match(pattern,studentinfo["ID"]):
   idflag = False
 
 studentinfo["語文"]=input("請輸入語文成績:")
 while not studentinfo["語文"].isdigit() or int(studentinfo["語文"])>100 or int(studentinfo["語文"])<0:
  studentinfo["語文"] = input("輸入錯誤,請重新輸入:")
 
 studentinfo["數(shù)學(xué)"]=input("請輸入數(shù)學(xué)成績:")
 while not studentinfo["數(shù)學(xué)"].isdigit() or int(studentinfo["數(shù)學(xué)"]) > 100 or int(studentinfo["數(shù)學(xué)"]) < 0:
  studentinfo["數(shù)學(xué)"] = input("輸入錯誤,請重新輸入:")
 
 studentinfo["英語"]=input("請輸入英語成績:")
 while not studentinfo["英語"].isdigit() or int(studentinfo["英語"]) > 100 or int(studentinfo["英語"]) < 0:
  studentinfo["英語"] = input("輸入錯誤,請重新輸入:")
 
 studentinfo["總分"]=int(studentinfo["語文"])+int(studentinfo["英語"])+int(studentinfo["數(shù)學(xué)"])
 student.append(studentinfo)
 
def delstudent():
 delstudentid = input("請輸入要刪除的學(xué)生學(xué)號:")
 flag =False
 for item in student:
  if item["ID"]==delstudentid:
   flag = True
   print("要刪除學(xué)生的相關(guān)信息如下:")
   print(item)
   select=input("是否刪除:是(Y)/否(N)")
   if select=="Y" or select=="y":
    student.remove(item)
    print("刪除成功")
   elif select =="N" or select=="n":
    print("取消刪除")
   else:
    print("輸入錯誤")
 if flag ==False:
  print("未搜索到該學(xué)生")
 
def querystudent(querystudentid):
 flag=False
 for item in student:
  if item["ID"]==querystudentid:
   flag=True
 return flag
 
def modifystudentifo():
 delstudentid = input("請輸入要修改的學(xué)生學(xué)號:")
 
 flag=False
 for item in student:
  if item["ID"]==delstudentid:
   print("查詢內(nèi)容如下:")
   print(item)
   flag=True
   while True:
    modifymenu = input("請輸入修改選項:1、姓名,2、語文成績,3、數(shù)學(xué)成績,4、英語成績,5、退出")
    while not modifymenu.isdigit():
     modifymenu = input("輸入錯誤,請重新輸入:")
    if int(modifymenu)==1:
     item["Name"] = input("請重新輸入學(xué)生姓名:")
    elif int(modifymenu)==2:
     item["語文"] = input("請重新輸入學(xué)生語文成績:")
    elif int(modifymenu)==3:
     item["數(shù)學(xué)"] = input("請重新輸入學(xué)生數(shù)學(xué)成績:")
    elif int(modifymenu)==4:
     item["英語"] = input("請重新輸入學(xué)生英語成績:")
    elif int(modifymenu) == 5:
     break
    else:
     print("輸入序號無效")
   item["總分"] = int(item["語文"]) + int(item["英語"]) + int(item["數(shù)學(xué)"])
   print("修改結(jié)果如下:")
   print(item)
 
 if flag ==False:
  print("未搜索到該學(xué)生")
 
def allinfo():
 for item in student:
  print(item)
 
def iteminfo(querystudentid):
 for item in student:
  if item["ID"]==querystudentid:
   print("查詢內(nèi)容如下:")
   print(item)
 
def studentMenu():
 print("="*30)
 print("學(xué)生管理系統(tǒng)")
 print("1、添加學(xué)生信息")
 print("2、刪除學(xué)生信息")
 print("3、查詢學(xué)生信息")
 print("4、修改學(xué)生信息")
 print("5、顯示所有學(xué)生信息")
 print("6、退出")
 print("="*30)
 
 
if __name__ == '__main__':
 
 while True:
  studentMenu()
  menuindex = input("請輸入選項序號:")
  while not menuindex.isdigit():
   menuindex = input("輸入錯誤,請重新輸入:")
  if int(menuindex) ==1:
   appendStudentInfo()
  elif int(menuindex) ==2:
   delstudent()
  elif int(menuindex) ==3:
   querystudentid = input("請輸入要查詢的學(xué)生學(xué)號:")
   if querystudent(querystudentid) == True:
    iteminfo(querystudentid)
   else:print("未搜索到該學(xué)生")
  elif int(menuindex) ==4:
   modifystudentifo()
  elif int(menuindex)== 5:
   allinfo()
  elif int(menuindex) == 6:
   break
  else:
   print("輸入序號無效")

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 利用python中的matplotlib打印混淆矩陣實例

    利用python中的matplotlib打印混淆矩陣實例

    這篇文章主要介紹了利用python中的matplotlib打印混淆矩陣實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-06-06
  • 利用Python Django實現(xiàn)簡單博客系統(tǒng)

    利用Python Django實現(xiàn)簡單博客系統(tǒng)

    這篇文章主要介紹了利用Python Django實現(xiàn)簡單博客系統(tǒng),文中有非常詳細的代碼示例,對正在學(xué)習(xí)python的小伙伴們有很好地幫助,需要的朋友可以參考下
    2021-05-05
  • python 如何快速找出兩個電子表中數(shù)據(jù)的差異

    python 如何快速找出兩個電子表中數(shù)據(jù)的差異

    下面小編就為大家?guī)硪黄猵ython 如何快速找出兩個電子表中數(shù)據(jù)的差異。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • 詳解DBSCAN算法原理及其Python實現(xiàn)

    詳解DBSCAN算法原理及其Python實現(xiàn)

    DBSCAN,即Density-Based Spatial Clustering of Applications with Noise,基于密度的噪聲應(yīng)用空間聚類,本文將詳細介紹DBSCAN算法的原理及其Python實現(xiàn),需要的可以參考下
    2023-12-12
  • python簡單實現(xiàn)操作Mysql數(shù)據(jù)庫

    python簡單實現(xiàn)操作Mysql數(shù)據(jù)庫

    本文給大家分享的是在python中使用webpy實現(xiàn)簡單的數(shù)據(jù)庫增刪改查操作的方法,非常的簡單,有需要的小伙伴可以參考下
    2018-01-01
  • 詳解Python常用標準庫之時間模塊time和datetime

    詳解Python常用標準庫之時間模塊time和datetime

    time和datetime是Python中常用的兩個時間模塊,本文將通過示例詳細為大家講講二者的使用方法,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)學(xué)習(xí)
    2022-05-05
  • Python數(shù)據(jù)可視化之Matplotlib和Seaborn的使用教程詳解

    Python數(shù)據(jù)可視化之Matplotlib和Seaborn的使用教程詳解

    這篇文章主要為大家詳細介紹了Python數(shù)據(jù)可視化中Matplotlib和Seaborn使用的相關(guān)教程,文中的示例代碼講解詳細,有需要的可以參考下
    2024-03-03
  • Python 流媒體播放器的實現(xiàn)(基于VLC)

    Python 流媒體播放器的實現(xiàn)(基于VLC)

    這篇文章主要介紹了Python 流媒體播放器的實現(xiàn)(基于VLC),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04
  • 詳解python中flask_caching庫的用法

    詳解python中flask_caching庫的用法

    這篇文章主要介紹了詳解python中flask_caching庫的用法,可以在一定的時間內(nèi)直接返回結(jié)果而不是每次都需要計算或者從數(shù)據(jù)庫中查找。flask_caching插件就是提供這種功能的神器,需要的朋友可以參考下
    2023-05-05
  • pytorch自定義初始化權(quán)重的方法

    pytorch自定義初始化權(quán)重的方法

    今天小編就為大家分享一篇pytorch自定義初始化權(quán)重的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08

最新評論