91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6KB
    文件類型: .py
    金幣: 1
    下載: 2 次
    發(fā)布日期: 2021-06-18
  • 語言: Python
  • 標(biāo)簽: 數(shù)據(jù)??

資源簡介

用簡單的Python代碼實(shí)現(xiàn)學(xué)生管理系統(tǒng),連接數(shù)據(jù)庫實(shí)現(xiàn)增刪改查

資源截圖

代碼片段和文件信息

import?sqlite3
import?sys
import?re
def?Prtstu():
??stulist=c.execute(“select?*?from?stu“)
??for?s?in?stulist:
????print(s)
def?Addstu():
??newname=input(“輸入姓名“)
??
??while?True:
????????num=input(“輸入學(xué)號(hào)“)
????????p=re.compile(r‘\d{9}$‘)
????????if?p.match(num):
????????????break
????????else:
????????????print(“輸入錯(cuò)誤,必需是9位數(shù)字“)
??while?True:
????????newscore=int(input(“輸入成績“))
????????if?newscore>=0?and?newscore<=100:
????????????break
????????else:
????????????print(“輸入錯(cuò)誤,必需是0-100之間的數(shù)字“)??
??save=input(“是否保存數(shù)據(jù)?Y/N“)
??if?save.upper()==“Y“:
???????c.execute(“insert?into?stu?values(???)“(numnewnamenewscore))
???????con.commit()
???????print(“保存數(shù)據(jù)成功!“)
def?Sbynum():
????inputnum=input(“請輸入要查找的學(xué)號(hào):“)
????c.execute(“select?*?from?stu?where??學(xué)號(hào)=?“(inputnum))
????print(c.fetchone())
????
def?Sbyname():
????inputname=input(“請輸入要查找的姓名:“)
????c.execute(“select?*?from?stu?where??學(xué)號(hào)=?“(inputname))
????print(c.fetchone())
def?Searchstu():
????print(“*****************************************“)
????print(“----------------菜單---------------------“)
????print(“根據(jù)學(xué)號(hào)查找----------------------------1“)
????print(“根據(jù)姓名查找----------------------------2“)
????print(“離開本模塊------------------------------3“)
????print(“*****************************************“)
????sc=input(“請輸入你的選擇“)
????if?sc==“1“:
????????Sbynum()
????elif?sc==“2“:
????????Sbyname()
????elif?sc==“3“:
????????Mainmenu()
????else:
????????print(“你的輸入有誤!“)
def?Dbynum():
????x=Sbynum()
????if?x!=-1:
????????save=input(“是否保存Y/y“)
????????if?save.upper()==“Y“:
????????????stulist.remove(x)
????????????f=open(“students.txt““w“)
????????????for?s?in?stulist:????????????????
????????????????str1=s.num+“??“+s.name+“???“+str(s.cj)+“??“+“\n“
????????????????f.write(str1)
????????????print(“保存成功!“)
def?Dbyname():
????x=Sbyname()
????if?x!=-1:
????????save=input(“是否保存Y/y“)
????????if?save.upper()==“Y“:
????????????stulist.remove(x)
????????????f=open(“students.txt““w“)
????????????for?s?in?stulist:????????????????
????????????????str1=s.num+“??“+s.name+“???“+str(s.cj)+“??“+“\n“
????????????????f.write(str1)
????????????print(“保存成功!“)????????????
def??Sortstu():
????pxlist=sorted(key=lambda?x:x.cj)
????Prtstu(pxlist)
def?Delstu():
????print(“*****************************************“)
????print(“----------------菜單---------------------“)
????print(“根據(jù)學(xué)號(hào)刪除----------------------------1“)
????print(“根據(jù)姓名刪除----------------------------2“)
????print(“離開本模塊------------------------------3“)
????print(“*****************************************“)
????sc=input(“請輸入你的選擇“)
????if?sc==

評(píng)論

共有 條評(píng)論

相關(guān)資源