Prologue: Write in front

As a mature and steady college students, our required course is not the maximum lazy? As the monitor, every time the face of a pile of documents, but also check who did not hand in, this is a very big thing !!!! Technology changes life, thanks to technology! Gave me the idea of writing code in Python to check homework with one click, without further ado! Source code!!

A, source

1. Result presentation

All:

Not all:

2, the source code

The python source code is as follows:

import glob import os import pandas as pd def unfinished(student_complete,student_lst): Result = [] # abnormal = [] for I in student_lst: if I am not in student_complete: result.append(i) for j in student_complete: if j not in student_lst: result_abnormal.append(j) if(len(result_abnormal) ! = 0): print(' Abnormal ',result_abnormal) return result def complete(file_lst): Result = [] # abnormal = [] # Abnormal for I in range (0,len(file_lst)): if (len(file_lst[I]) == 28): result.append(file_lst[i][14:17]) elif(len(file_lst[i]) == 27): result.append(file_lst[i][14:16]) else: result_abnormal.append(file_lst[i]) if (len(result_abnormal) ! = 0): print(' abnormal 'return result def roster(path_roster): Read_excel (path_roster, usecols=[2],names=None) List df_lit = df_lit. Tolist () # convert to a list result = [] for s_lit in df_lit: result.append(s_lit[0]) return result def Making_list(file_dir,path_roster): Student_lst = os.listdir(file_dir) student_complete = complete(file_lst) student_lst = Roster (path_roster) # Unfinished student list student_Making = unfinished(student_complete,student_lst) return student_Making,len(student_complete) if __name__ == '__main__': # define the jobs folder path_file = 'D:\Desktop > OS select The first job '# Define the roster path path_roster = 'D:\Desktop > OS select the roster. XLSX' # Num = Making_list(path_file, path_roster) if (len(LST) == 0): print(len(LST) else: Print (' print ',' print '; Number of assignments submitted: ',num,'; Print (' ','\n', LST) print(' ','\n', LST)Copy the code

Second, source annotations

1. Dependency packages used

There are three dependency packages used, as follows:

The # glob module provides a wide range of functions and methods for handling files and directories. The # glob module provides a wide range of functions and methods for handling data quickly and easilyCopy the code

Dependency package installation:

PIP install glob PIP install OS PIP install pandasCopy the code

2. Call the function

The custom functions used are as follows:

Def unfinished(student_complete,student_lst): def complete(file_lst): Def roster(path_roster): def Making_list(file_dir,path_roster):Copy the code

Three, use method

Custom functions do not need to be changed. Need to change as follows:

Just change the assignments folder path and class roster path to the local path. if __name__ == '__main__': # define job folder path_file = 'D: Desktop: OS select Lecture first job '# Define roster path_roster = 'D: Desktop: OS select Lecture roster. XLSX'Copy the code

Roster style:

File naming format:

Student id + name + several assignments for example: 0000000000000+ black + first assignment

Student number needs 13 digits, not enough 13 digits can be filled with 0. For one-click file renaming, go to the home page.

Recently, many friends have sent messages to ask about learning Python. For easy communication, click on blue to join yourselfDiscussion solution resource base