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(‘移动完成‘)