20.10.21 python文件重命名和移动
作者:
mpcv | 来源:发表于
2020-10-21 10:07 被阅读0次#复制文件:
shutil.copyfile("oldfile","newfile") #oldfile和newfile都只能是文件
shutil.copy("oldfile","newfile") #oldfile只能是文件夹,newfile可以是文件,也可以是目标目录
#复制文件夹:
shutil.copytree("olddir","newdir") #olddir和newdir都只能是目录,且newdir必须不存在
#重命名文件(目录)
os.rename("oldname","newname") #文件或目录都是使用这条命令
#移动文件(目录)
shutil.move("oldpos","newpos")
shutil.move("D:/知乎日报/latest/一张优惠券,换你的通讯录信息,你愿意吗?.pdf", "D:/知乎日报/past/")
本文标题:20.10.21 python文件重命名和移动
本文链接:https://www.haomeiwen.com/subject/rxesmktx.html
网友评论