import os
import shutil
def copyfile(srcfile, dst_path):
# srcfile 需要复制、移动的文件(文件路径+文件名)
# dstpath 目的路径(要复制到哪里去)
if not os.path.isfile(srcfile):
print("%s not exist!" % srcfile)
else:
fpath, f_name = os.path.split(srcfile) # 分离文件名和路径
if not os.path.exists(dst_path): # 如果目的路径不在则创建目的路径
os.makedirs(dst_path) #
shutil.copy(srcfile, dst_path + f_name) # 复制文件
python:复制文件到指定地址下(文件名不变)
最新推荐文章于 2023-12-20 15:16:45 发布