import shutil # with open('d.txt','r')as f1,open('new','w')as f: # shutil.copyfileobj(f1,f) # shutil.copyfileobj(open('db.txt','r'), open('new.txt', 'w')) #将文件内容拷贝到另一个文件中 # shutil.copyfile('new.txt','new2.txt') #直接写文件名,目标文件无需存在 # shutil.copymode('new.txt','new2.txt') # 仅拷贝权限,内容、组、用户 都不变,目标必须存在 # shutil.copystat('new.txt','new2.txt') # 仅拷贝状态信息,有mode bits atime mtime flags,目标必须存在 # shutil.make_archive('date_back','gztar',root_dir='D:\老男孩\脱产班py二期\代码统计练习\dir') # 将文件夹内容打包压缩成date_back.tar.gz文件 # import tarfile # t=tarfile.open('date_back.tar.gz','r') # t.extractall('D:\老男孩\脱产班py二期\代码统计练习\dic3') # t.close() #把文件解压缩到新文件夹中,目标文件无需存在
python的shutil模块
猜你喜欢
转载自blog.csdn.net/qq_35540539/article/details/80807755
今日推荐
周排行