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 @ 2015-11-02 16:09  米 立  阅读(51696)  评论(1编辑  收藏  举报