python实现拷贝指定文件到指定目录

python实现这个功能非常简单,因为库太强大了

复制代码
import os
import shutil
alllist=os.listdir(u"D:\\notes\\python\\资料\\")
for i in alllist:
    aa,bb=i.split(".")
    if 'python' in aa.lower():
        oldname= u"D:\\notes\\python\\资料\\"+aa+"."+bb
        newname=u"d:\\copy\\newname"+aa+"."+bb
        shutil.copyfile(oldname,newname)
复制代码

 

posted @   米 立  阅读(51717)  评论(1编辑  收藏  举报
点击右上角即可分享
微信分享提示