import os import pymysql from fnmatch import fnmatch aaa=input(r'请输入存放作业的绝对路径:') filename=os.listdir(aaa) #获取绝对路径 import pymysql import pandas db=pymysql.connect(host='localhost',port=3306,user='root',database='lihao',password='lh19990317') #cursor=db.cursor() sql='select name from sanban' data1=pandas.read_sql_query(sql,db) s=data1.shape[0] ls=[] for i in range(s): t=data1['name'].at[i].strip() ls.append(t) w=[] for i in range(len(filename)): a=aaa+os.sep+filename[i] b=os.path.basename(a) w.append(b) cc='-'.join(w) for i in range(41): if fnmatch(cc,'*'+ls[i]+'*'): pass else: print('{}没有交作业'.format(ls[i]))