当前位置:网站首页>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
边栏推荐
猜你喜欢
Word中批注的使用方法
【PYTORCH】RuntimeError: one of the variables needed for gradient computation has been
26 | Superscalar和VLIW:如何让CPU的吞吐率超过1
v-for生成的子组件列表删除第n行出现数据错乱问题
2022年电工(初级)考题及模拟考试
分布式系统之道:Lamport 逻辑时钟
20 | pipeline oriented instruction design (Part 1): Modern CPU with multi-purpose
21 | pipeline oriented instruction design (Part 2): How did Pentium 4 fail?
Remote office solution under epidemic situation
ES6 deleting an attribute of an object
随机推荐
[tools for quickly creating MySQL stand-alone and cluster test environments] dbdeployer
25 | adventure and prediction (IV): it's raining today. Will it rain tomorrow?
leetcode 咒语和药水的成功对数
BD新标签页(BdTab)插件如何登入?
本地靶场2-文件上传漏洞(三)-网络安全
20 | pipeline oriented instruction design (Part 1): Modern CPU with multi-purpose
Data disorder occurs when the n-th row of the subcomponent list generated by V-for is deleted
MySQL source code --table_ cache
25 | 冒险和预测(四):今天下雨了,明天还会下雨么?
es6删除对象的某个属性
Dfinity (ICP) deployment and development-2
Dfinity (ICP) basic development tutorial-5
Redis underlying data structure ----quicklist
Recommend several books on DBA promotion
JMeter UDP pressure measurement
Selenium reports an error deprecationwarning: executable_ path has been deprecated, please pass in a Service object
23 | 冒险和预测(二):流水线里的接力赛
将solidworks建的机器人模型导入到ros中
Structural analysis of hyperledger fabric (I)
udf_ interval_ to_ Hourno() function