import os,shutil
def movefile(srcfile, destfile):
if not os.path.isfile(srcfile):
print('%s not exists' %(srcfile))
else:
fpath,fname=os.path.split(destfile)
if not os.path.exists(fpath):
os.makedirs(fpath)
shutil.move(srcfile,destfile)
print('move %s --> %s' %(srcfile, destfile))
srcfile=r'C:\Users\Administrator\Desktop\cvm_init.log'
dstfile=r'C:\Users\Administrator\Desktop\test\cvm_init.log'
movefile(srcfile,dstfile)
python移动文件
最新推荐文章于 2024-04-24 18:22:20 发布