python基于mysql的学生_Python基于mysql实现学生管理系统

import pymysql

import re

def idinput(string):

ID = input(string)

pattern = re.compile("^\d{1,3}$")

while not re.match(pattern, ID):

ID = input("请输入1-3位整数:")

return ID

def appendStudentInfo():

ID =idinput("请输入学生学号:")

db=pymysql.connect(host="127.0.0.1",user="root",passwd="hisense",db="test",port=3306,charset="utf8")

cursor=db.cursor()

sql = "select * from StuSys where ID = '%s'" % ID

cursor.execute(sql)

while cursor.rowcount > 0 :

ID = idinput("该学号已存在,请重新输入:")

sql = "select * from StuSys where ID = '%d'" % int(ID)

cursor.execute(sql)

name=input("请输入学生姓名:")

chinese=input("请输入语文成绩:")

while not chinese.isdigit() or int(chinese)>100 or int(chinese)<0:

chinese = input("输入错误,请重新输入:")

math =input("请输入数学成绩:")

while not math.isdigit() or int(math) > 100 or int(math) < 0:

math = input("输入错误,请重新输入:")

english=input("请输入英语成绩:")

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值