# -*- coding : utf-8 -*-
# @Time : 2020/12/25 16:06
# @author : 王小王
# @Software : PyCharm
# @File : stu_attendance.py
# @CSDN : https://blog.csdn.net/weixin_47723732
import csv
import time
student_infos = []
def load_stu_info():
"""
加载学生信息
从stu_infos.csv文件中加载数据
:return: 无
"""
with open(r"stu_infos.csv", encoding='utf-8-sig') as file:
f_csv = csv.reader(file)
header = next(f_csv)
for row in f_csv:
student_info = {}
for index in range(3):
student_info[header[index]] = row[index]
student_infos.append(student_info)
def login():
"""
用户使用学号和密码进行登录
最多让用户登录三次,如果连续三次都登录失败(用户名或者密码错误),只要密码和用户都正确表示登录成功
:return:登录成功返回True和学号,三次都登录失败返回False和None
"""
retry_time = 0
while retry_time < 3:
user_no = input('请输入登录账号:')
password = input('请输入密码:')
for i in student_infos:
if i['no']==user_no and i['password']==password:
return True,user_no
print('用户名或者密码错误!!!请重新输入。')
retry_time += 1
else:
return False, None
def add(user_no):
for x in student_infos:
if user_no==x['no']:
name=x['name']
break
times=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
choices=['出勤','迟到','请假','缺勤']
a=int(input("\t该学生出勤情况:1-出勤\t2-迟到\t3-请假\t4-缺勤:"))
if a==1:
data=choices[0]
elif a==2:
data=choices[1]
elif a==3:
data=choices[2]
else:
data=choices[3]
with open(r"attendance.csv",'a+',newline='', encoding='utf-8') as f:
wf = csv.writer(f)
wf.writerow([user_no,name,times,data])#写入一行数据
print("{}同学{}数据已经写入成功!操作时间是{}".format(name,data,times))
def select():
student = []
with open(r"attendance.csv", encoding='utf-8-sig') as file:
f_csv = csv.reader(file)
header = next(f_csv)
for row in f_csv:
students = {}
for index in range(4):
students[header[index]] = row[index]
student.append(students)
name=input("请输入你需要查找的姓名:")
print(" 学号\t\t姓名\t\t操作时间\t\t出勤状态")
for a in student:
if a['name']==name:
print(a['no']+'\t'+a['name']+'\t'+a['time']+'\t\t'+a['state'])
else:
print("无此人!!!")
break
Python考勤系统源码(增删改查)
版权申诉
5星 · 超过95%的资源 153 浏览量
2022-02-10
11:38:32
上传
评论
收藏 8KB RAR 举报
王小王-123
- 粉丝: 6w+
- 资源: 106
最新资源
- 407000001.fasset
- J-20240402998-HTE-HTE-2947110DA-D3_整车运动控制器-电压渐变(缓升缓降)-检测报告-XS-汽车及零部件检测中心.pdf.crdownload
- Excel表格VBA-获取文件夹内所有文件路径.zip
- 文件移动.zip
- 反射源代码,源代码,源代码,源代码
- CAJViewer 9.0_x64-setup.exe
- servant C++语言框架rpc的源码实现 tools C++语言框架IDL工具的源码实现 util C++语言.7z
- 使用pyqt创建一个登录具有动态背景的登陆界面
- 实验名称 调幅波信号的解调
- 实验名称 振幅调制器(利用乘法器)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
前往页