老师要求班级打卡查人数,总有人忘记打卡,消息也不看,一个一个找太浪费时间了,终于我开始对他们下手了。
from xlrd import open_workbook fname = r'wg.xls' rname = r'dk.txt' xname = r'dkkk.txt' data = open_workbook(fname) table = data.sheets()[0] cols = table.col(0) with open(rname, encoding='UTF-8') as f: data = f.read() # 读取文件 for col in cols: if str(col.value) not in data: with open(xname, "a") as j: j.write(col.value) j.write("\r")
代码在这,wg存放班级人名,dk放打卡信息,dkkk是未打卡人。