python版學(xué)生管理系統(tǒng)的示例分析-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)python版學(xué)生管理系統(tǒng)的示例分析,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

目前創(chuàng)新互聯(lián)已為千余家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、成都網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計、婺城網(wǎng)站維護(hù)等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

示例

input("\n\nPress the enter key to exit.")


def functionList(): # 定義功能菜單
 print("---------請輸入序號選擇您要得功能---------")
 print("")
 print("-" * 14 + "1.查看學(xué)生信息" + "-" * 14)
 print("-" * 42)
 print("-" * 14 + "2.增加學(xué)生信息" + "-" * 14)
 print("-" * 42)
 print("-" * 14 + "3.刪除學(xué)生信息" + "-" * 14)
 print("-" * 42)
 print("-" * 14 + "4.修改學(xué)生信息" + "-" * 14)
 print("-" * 42)
 print("-" * 14 + "5.查找系統(tǒng)學(xué)生" + "-" * 14)
 print("-" * 42)
 print("-" * 14 + "6.返回到上一級" + "-" * 14)
 print("-" * 42)
 print("-" * 14 + "7.退出學(xué)生系統(tǒng)" + "-" * 14)
 print("")


def functionList2(): # 定義簡單版功能菜單

 print("---1:查看----2:增加-----3:刪除----4:修改----")
 print("-------5:查找-------6:返回------7:退出------")


def sexInputDebug(sexInput): # 檢查性別輸入是否正確
 if len(sexInput) == 1 and (sexInput.lower() == "m" or sexInput.lower() == "f"):
 return True
 else:
 return False


def ageInputDebug(ageInput): # 檢查年齡輸入是否正確
 if len(ageInput) == 2 and ageInput.isdigit() == True:
 return True
 else:
 return False


def IDInputDebug(IDInput): # 檢查學(xué)號輸入是否正確
 if len(IDInput) == 8 and IDInput.isdigit() == True:
 return True
 else:
 return False


def nameListFunction(): # 顯示單個學(xué)生姓名信息
 nameList = []
 for i in range(len(studentList)):
 if studentList[i]["name"] not in nameList:
  nameList.append(studentList[i]["name"])
 return nameList


def findNameLocation(studentname): # 通過名字找到學(xué)生位置
 for j in range(len(studentList)):
 if studentList[j]["name"] == studentname:
  return j


def listFunction(): # 定義顯示現(xiàn)有學(xué)生信息函數(shù)
 for i in range(len(studentList)):
 studentInfo = studentList[i]
 print("姓名:%s--性別:%s--年齡:%s--學(xué)號:%s--備注:%s--" % (
 studentInfo["name"], studentInfo["sex"], studentInfo["age"], studentInfo["studentID"], studentInfo["extra"]))
 print("")


def addFunction(): # 定義增加學(xué)生函數(shù)

 while True:
 numInput =input("-----修改已經(jīng)存在的學(xué)生備注請輸入1\n-----------增加一個新的學(xué)生請輸入2:")
 if numInput == "2":
  while True:
  nameNoExistAdd = input("請輸入您要增加的名字:")

  nameList = nameListFunction()
  if nameNoExistAdd in nameList:
   print("%s在學(xué)生管理系統(tǒng)中已經(jīng)存在" % nameNoExistAdd)
   print("")

  else:
   newStudent = {}
   newStudent["name"] = nameNoExistAdd
   while True:
   sexInput = input("----請輸入%s的性別--f:man--m:women:" % nameNoExistAdd)
   if sexInputDebug(sexInput) == True:
    newStudent["sex"] = sexInput
    break
   else:
    print("輸入有誤,請重新輸入!")
   while True:
   ageInput = input("-------請輸入%s2位數(shù)字表示的年齡:" % nameNoExistAdd)
   if ageInputDebug(ageInput) == True:
    newStudent["age"] = ageInput
    break
   else:
    print("輸入有誤,請重新輸入!")
   while True:
   IDInput = input("----------請輸入%s的8位學(xué)號:" % nameNoExistAdd)
   if IDInputDebug(IDInput) == True:
    newStudent["studentID"] = IDInput
    break
   else:
    print("輸入有誤,請重新輸入!")
   extraInput = input("----------請輸入%s的備注:" % nameNoExistAdd)
   newStudent["extra"] = extraInput
   studentList.append(newStudent)
   print("--------------%s已經(jīng)添加到學(xué)生管理系統(tǒng)" % nameNoExistAdd)
   print("")
   print("姓名:%s--性別:%s--年齡:%s--學(xué)號:%s--備注:%s--" % (
   newStudent["name"], newStudent["sex"], newStudent["age"], newStudent["studentID"],
   newStudent["extra"]))
   break
  break
 elif numInput == "1":
  while True:
  nameExistAdd = input("------請輸入您要修改備注的學(xué)生的名字:")
  nameList = nameListFunction()
  if nameExistAdd in nameList:
   extraExistAdd = input("-----------------請輸入您要添加的備注:")
   j = findNameLocation(nameExistAdd)
   studentList[j]["extra"] = extraExistAdd
   print("---------------備注已經(jīng)添加--------------")
   print("")
   print("姓名:%s--性別:%s--年齡:%s--學(xué)號:%s--備注:%s--" % (
   studentList[j]["name"], studentList[j]["sex"], studentList[j]["age"], studentList[j]["studentID"],
   studentList[j]["extra"]))
   print("")
   break
  else:
   print("-----------------您輸入的姓名不存在")
  break

 else:
  print("----------------您輸入的信息不正確")


def delFunction(): # 定義刪除學(xué)生的函數(shù)
 while True:
 nameDel = input("---------------請輸入您要刪除的名字:")
 studentNameList = nameListFunction()
 if nameDel in studentNameList:
  j = findNameLocation(nameDel)

  del studentList[j]
  print("-------------%s已經(jīng)從學(xué)生管理系統(tǒng)中刪除" % nameDel)
  print("")
  break
 else:
  print("------------------您要刪除的名字不存在!")


def modifiFunction(): # 定義修改學(xué)生的函數(shù)
 while True:
 nameModifi = input("----------------請輸入要修改的名字:")
 studentNameList = nameListFunction()
 if nameModifi in studentNameList:
  print("------------請選擇要修改的內(nèi)容-----------")
  print("--------------1:修改姓名---------------")
  print("--------------2:修改性別---------------")
  print("--------------3:修改年齡---------------")
  print("--------------4:修改學(xué)號---------------")
  print("--------------5:修改備注---------------")

  while True:
  choiceInput = input("請輸入:")
  if choiceInput == "1":
   newNameInput = input("----------請輸入新的姓名:")
   j = findNameLocation(nameModifi)
   studentList[j]["name"] = newNameInput
   print("------------姓名已經(jīng)更新------------")
   print("")
   break
  elif choiceInput == "2":
   while True:
   newSexInput = input("----請輸入新的性別--f:man--m:women---")
   if sexInputDebug(newSexInput) == True:
    j = findNameLocation(nameModifi)
    studentList[j]["sex"] = newSexInput
    print("-------------性別已經(jīng)更新-------------")
    print("")
    break
   else:
    print("---------輸入有誤,請重新輸入!---------")
   break
  elif choiceInput == "3":
   while True:
   newAgeInput = input("----------請輸入新的年齡:")
   if ageInputDebug(newAgeInput) == True:
    j = findNameLocation(nameModifi)
    studentList[j]["age"] = newAgeInput
    print("------------年齡已經(jīng)更新------------")
    print("")
    break
   else:
    print("----------入有誤,請重新輸入!-------")
   break
  elif choiceInput == "4":
   while True:
   newIDInput = input("----------請輸入新的學(xué)號:")
   if IDInputDebug(newIDInput) == True:
    j = findNameLocation(nameModifi)
    studentList[j]["studentID"] = newIDInput
    print("------------學(xué)號已經(jīng)更新------------")
    print("")
    break
   else:
    print("----------入有誤,請重新輸入!-------")
   break
  elif choiceInput == "5":
   newExtraInput = input("----------請輸入新的備注:")
   j = findNameLocation(nameModifi)
   studentList[j]["extra"] = newExtraInput
   print("------------備注已經(jīng)更新------------")
   print("")
   break
  else:
   print("---------輸入有誤,請重新輸入!-------")
   print("")
  break
 else:
  print("-----------------您輸入的名字不存在!")
  print("")


def searchFunction(): # 定義搜索學(xué)生的函數(shù)
 nameSearch = input("-------------請輸入要查找的名字:")
 print("")
 nameList = nameListFunction()
 if nameSearch in nameList:
 print("-----------------%s在學(xué)生管理系統(tǒng)中-------------------" % nameSearch)
 print("")
 j = findNameLocation(nameSearch)
 print("姓名:%s--性別:%s--年齡:%s--學(xué)號:%s--備注:%s--" % (
 studentList[j]["name"], studentList[j]["sex"], studentList[j]["age"], studentList[j]["studenID"],
 studentList[j]["extra"]))
 print("")
 else:
 print("----------------%s不在學(xué)生管理系統(tǒng)中-----------------" % nameSearch)
 print("")
 # 默認(rèn)學(xué)生信息系統(tǒng)內(nèi)容


studentList = [{"name": "Frank", "sex": "f", "age": 33, "studentID": "312312", "extra": ""},
  {"name": "Jane", "sex": "m", "age": 45, "studentID": "324235", "extra": ""}]

# 函數(shù)主體
print("-" * 11 + "歡迎來到學(xué)生管理系統(tǒng)" + "-" * 11)
print("")
print("")
functionList()
while True: # 進(jìn)入循環(huán),根據(jù)序號選擇操作
 userInput = input("----------------請輸入您要選擇的功能序號:")
 print("")

 if userInput == "1": # 顯示現(xiàn)有學(xué)生和返回
 listFunction()
 functionList2()
 continue
 elif userInput == "2": # 使用增加函數(shù)和返回
 addFunction()
 functionList2()
 continue
 elif userInput == "3": # 使用刪除函數(shù)和返回
 delFunction()
 functionList2()
 continue
 elif userInput == "4": # 使用修改函數(shù)和返回
 modifiFunction()
 functionList2()
 continue
 elif userInput == "5": # 使用搜索函數(shù)和返回
 searchFunction()
 functionList2()
 continue
 elif userInput == "6": # 返回功能列表
 functionList()
 continue
 elif userInput == "7": # 退出
 break
 else:
 print("----------輸入有誤,請重新輸入!----------")

以下就是運(yùn)行后的結(jié)果:

python版學(xué)生管理系統(tǒng)的示例分析

python版學(xué)生管理系統(tǒng)的示例分析

關(guān)于“python版學(xué)生管理系統(tǒng)的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

文章標(biāo)題:python版學(xué)生管理系統(tǒng)的示例分析-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://muchs.cn/article12/ddcddc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、關(guān)鍵詞優(yōu)化、網(wǎng)站設(shè)計、軟件開發(fā)、ChatGPT、App設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)