当前位置:网站首页>set实现名单查找与排除
set实现名单查找与排除
2022-06-13 08:02:00 【sichuanwww】
利用几何set的运算,实现名单查找与排除
set差值 s1-s2
set交集 s1&s2
set并集s1|s2
import os
import shutil
#读取学生名单
listName=[]
with open("name.txt",encoding="utf-8") as file:
for item in file:
item = item.rstrip('\n')
listName.append(item)
#print(listName)
#读取目录下的全部文件
file_dir="申请表"
for root, dirs, files in os.walk(file_dir):
pass
#print(files)
#处理拥有论文的人员名单
full_path ='nameWithPapaer.txt'
paperfile = open(full_path, 'w')
listPaper=[]
#匹配文件
target_path="目标文件夹"
for stuName in listName:
for stuPaper in files:
if stuPaper.count(stuName)>0:
#拷贝文件
src_file="申请表\\"+stuPaper
shutil.copy(src_file, target_path)
print(stuPaper,"拷贝完毕")
#写文件
paperfile.write(stuName+"\n")
listPaper.append(stuName)
paperfile.close()
#处理没有论文的人员名单
full_path ='nameNoPapaer.txt'
nopaperfile = open(full_path, 'w')
#利用set进行差值运算
s1=set(listName)
s2=set(listPaper)
s3=set(s1-s2)
for i in s3:
nopaperfile.write(i+"\n")
nopaperfile.close()
print("处理完毕!")
input("任意键结束")
集合运算
边栏推荐
- SFTP login and download file script
- Redis persistence -- AOF
- MySQL interview questions
- [MySQL] online lock free delay free DDL artifact GH OST
- [MySQL] methods for troubleshooting lock related problems
- Get properties of class
- [deep learning]: introduction to pytorch to project practice (XII) convolutional neural network: padding and stride
- 2022起重机械指挥考试题模拟考试题库及在线模拟考试
- 20 | 面向流水线的指令设计(上):一心多用的现代CPU
- How app inventor accesses resource files in assets directory
猜你喜欢

SolidWorks修改工程图中文字字体的方法

【Emgu.CV】Emgu. CV. Example\ocr operation reports an error system IO. Filenotfoundexception: "failed to load file or assembly" system.drawing.common "

Give code vitality -- the way to read code neatly

4. fabric2.2 create and join channels (use the official demo)

Edge浏览器如何安装BdTab(BD)新标签页插件(图文教程)

19 | 建立数据通路(下):指令+运算=CPU

20 | pipeline oriented instruction design (Part 1): Modern CPU with multi-purpose

AcWing 1977. 信息中继(基环树,并查集)

6. fabric2.2 stop clustering and delete data (use the official demo)

Win10系统如何修改桌面路径
随机推荐
2022 simulated examination question bank and online simulated examination of hoisting machinery command examination questions
22 | adventure and prediction (I): hazard is both "danger" and "opportunity"
uniapp 小程序根据权限动态生成 tabbar
【PYTORCH】RuntimeError: one of the variables needed for gradient computation has been
String source code analysis
4. fabric2.2 create and join channels (use the official demo)
Hashtable source code analysis
IDS persistence ---rdb
26 | Superscalar和VLIW:如何让CPU的吞吐率超过1
2022年G3锅炉水处理操作证考试题库模拟考试平台操作
EHD ether coin, the hottest dpoc mining project
26 | superscalar and VLIW: how to make the CPU throughput exceed 1
20 | 面向流水线的指令设计(上):一心多用的现代CPU
Practice makes sense -- your byte alignment and stack cognition may be wrong
Amino encoding protocol
[tools for quickly creating MySQL stand-alone and cluster test environments] dbdeployer
【PYTORCH】RuntimeError: torch. cuda. FloatTensor is not enabled.
leetcode 咒语和药水的成功对数
Redis persistence -- AOF
17. how to understand multi version concurrency control and read / write sets of fabric smart contracts? (vernacular version)