python移动目录下所有子目录文件到新的总目录
作者:互联网
python移动目录下所有子目录文件到新的总目录
import os import shutil def file(p): p=p z=os.listdir(p) for i in z: if not (os.path.isfile(os.path.join(p,i))): pp=os.path.join(p,i) file(pp) else: zz=os.listdir(p) for k in zz: paa.append(os.path.join(p,k)) if __name__ == '__main__': p = 'F:\meizhuo' n_p = 'F:\zmeizhuo' paa = [] file(p) for f in paa: try: shutil.move(f,n_p) except: continue print('移动完成')
标签:__,join,python,总目录,子目录,paa,file,path,os 来源: https://www.cnblogs.com/68xi/p/11665951.html