学委小助手

开发背景

由于是某苦逼学委,经常遇到少数几个人没交作业的情况。该代码可以帮助清点作业,希望能帮到大家。

代码部分

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
import pandas as pd
folder_path = r''#配置你自己的文件夹路径eg:C:\Users\86159\Desktop\项目管理论文
excel_path = r""#配置你自己的名单路径eg:D:\user\班级资料\名单.xlsx
files_in_folder = [f for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))]
df = pd.read_excel(excel_path)
df['是否包含'] = '否'
for index, row in df.iterrows():
name_to_check = row['Name'] # 在你的Excel中创建一个名为'Name'的列,否则这一行会报错
for file in files_in_folder:
if name_to_check in file:
df.at[index, '是否包含'] = '是'
break
for index, row in df.iterrows():
if row['是否包含'] == '否':
print(row['Name'])