当前位置:网站首页>Set implements list search and exclusion
Set implements list search and exclusion
2022-06-13 08:05:00 【sichuanwww】
Use geometry set Arithmetic , Realize list search and exclusion
set Difference value s1-s2
set intersection s1&s2
set Combine s1|s2
import os
import shutil
# Read student list
listName=[]
with open("name.txt",encoding="utf-8") as file:
for item in file:
item = item.rstrip('\n')
listName.append(item)
#print(listName)
# Read all the files in the directory
file_dir=" The application form "
for root, dirs, files in os.walk(file_dir):
pass
#print(files)
# Process the list of people who have papers
full_path ='nameWithPapaer.txt'
paperfile = open(full_path, 'w')
listPaper=[]
# Match file
target_path=" Destination folder "
for stuName in listName:
for stuPaper in files:
if stuPaper.count(stuName)>0:
# Copy files
src_file=" The application form \\"+stuPaper
shutil.copy(src_file, target_path)
print(stuPaper," Copy complete ")
# Writing documents
paperfile.write(stuName+"\n")
listPaper.append(stuName)
paperfile.close()
# List of persons handling papers without papers
full_path ='nameNoPapaer.txt'
nopaperfile = open(full_path, 'w')
# utilize set Perform the difference operation
s1=set(listName)
s2=set(listPaper)
s3=set(s1-s2)
for i in s3:
nopaperfile.write(i+"\n")
nopaperfile.close()
print(" Finished processing !")
input(" Any key ends ")
Set operations
边栏推荐
- 2022年危险化学品经营单位安全管理人员特种作业证考试题库及模拟考试
- 生鲜配送分拣管理系统哪家比较强?
- 2022起重机械指挥考试题模拟考试题库及在线模拟考试
- Altium Designer中导入和导出设置的方法
- Recommend several books on DBA promotion
- es6删除对象的某个属性
- 母婴用品批发行业使用管理软件提高效率 实现降本增效
- Redis underlying data structure - underlying principle of hash table
- Redis underlying data structure ----quicklist
- Cosmos Starport installation and startup
猜你喜欢
【Emgu.CV】Emgu.CV.Example\OCR运行报错System.IO.FileNotFoundException:“未能加载文件或程序集“System.Drawing.Common
Redis underlying data structure - underlying principle of hash table
Overview of cross chain protocol IBC
[MySQL change master error] slave is not configured or failed to initialize properly
[redis problem] record a big key problem handling
Recognition of COVID-19 based on paddlepaddle
EHD ether coin, the hottest dpoc mining project
Remote office solution under epidemic situation
Tidb certification guide PCTA Pctp
v-for生成的子组件列表删除第n行出现数据错乱问题
随机推荐
适合生鲜批发行业的几种精准接单方式
3. deploy the fabric2.2 cluster (use the official demo)
Overview of cross chain protocol IBC
Motiko basic syntax in dfinity (ICP) -8
分布式系统之道:Lamport 逻辑时钟
SFTP login and download file script
【博弈论-完全信息静态博弈】 Nash均衡的应用
26 | Superscalar和VLIW:如何让CPU的吞吐率超过1
Data disorder occurs when the n-th row of the subcomponent list generated by V-for is deleted
本地靶场2-文件上传漏洞(三)-网络安全
[MySQL] the most complete MySQL monitoring project
酒水批发行业应当如何高效管理商品与库存
Edge浏览器使用BdTab新标签页插件(BD新标签页)
Redis master-slave replication - the underlying principle of partial resynchronization
Go 接口实现原理【高阶篇】: type _interface struct
Redis underlying data structure -- listpack
C盘爆满?简单几招教你释放、清理C盘几十G空间,最有效的C盘清理方法
Dfinity (ICP) deployment and development-2
Selenium reports an error deprecationwarning: executable_ path has been deprecated, please pass in a Service object
5. fabric2.2 installation and submission contract (using official demo)