当前位置:网站首页>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("任意键结束")
集合运算
边栏推荐
- Operation of simulated examination platform for examination question bank of G3 boiler water treatment operation certificate in 2022
- 基于paddlepaddle的新冠肺炎识别
- P7712 [Ynoi2077] hlcpq
- 2022起重机械指挥考试题模拟考试题库及在线模拟考试
- Redis underlying data structure -- listpack
- 2022 electrician (elementary) examination questions and simulation examination
- 2022年G3锅炉水处理操作证考试题库模拟考试平台操作
- 23 | 冒险和预测(二):流水线里的接力赛
- DATE_ SUB()
- Get properties of class
猜你喜欢
【深度学习】:《PyTorch入门到项目实战》(十二)卷积神经网络:填充(padding)和步幅(stride)
2021-10-08
Consistency under distributed
ERP基础数据 金蝶
分布式系统之道:Lamport 逻辑时钟
Edge浏览器如何安装BdTab(BD)新标签页插件(图文教程)
适合生鲜批发行业的几种精准接单方式
Selenium reports an error deprecationwarning: executable_ path has been deprecated, please pass in a Service object
Redis underlying data structure -- listpack
汽配行业面临的难题用什么软件帮忙解决呢
随机推荐
MySQL summary
Redis persistence -- AOF
MySQL table partitioning
EHD ether coin, the hottest dpoc mining project
[an example of MySQL startup error] innodb: failed to create check sector file, errno:13
3. deploy the fabric2.2 cluster (use the official demo)
P7712 [Ynoi2077] hlcpq
Overview of cross chain protocol IBC
批发商为什么要使用订单系统
赋予代码生命力--读代码整洁之道
Redis master-slave replication - underlying principle
基于paddlepaddle的新冠肺炎识别
Selenium reports an error deprecationwarning: executable_ path has been deprecated, please pass in a Service object
Redis Cluster - the underlying principle of slot assignment
Openharmony notes ----------- (I)
Examination question bank and simulation examination for special operation certificate of safety management personnel of hazardous chemical business units in 2022
母婴用品批发行业使用管理软件提高效率 实现降本增效
JMeter UDP pressure measurement
Differences between Merkle DAG and Merkle tree
ERP 基础数据 概念