import os
import shutil
def take_samefile(or_path, tar_path, tar_type):
tar_path = tar_path
if not os.path.exists(tar_path):
os.makedirs(tar_path)
path = or_path
files = os.listdir(path) # 读取or_path文件列表
for file in files:
file_type = str(file).split('.')[1] # 读取文件后缀
if file_type == tar_type:
print("take{}from{}".format(file, files))
dir = path + '/' + file # 存储文件路径
deter = tar_path + '/' + str(file)
shutil.copyfile(dir, deter)
if __name__ == "__main__":
take_samefile(r"", r"", "")