没车没房黄金剩女版,情骚,混合马里奥无敌版
import shutil
高级的文件,文件夹,压缩包的处理模块,也主要用于文件的拷贝
shutil.copyfileobj(fsrc,fdst[,length]): 将文件的内容拷贝到另一个文件(可以指定length长度进行拷贝)
import shutil shutil.copyfileobj(open('old.txt','r'),open('new.txt','w'))
shutil.copyfile(src,dst): 拷贝文件
import shutil shutil.copyfile('f1.log','f2.log')
shutil.copymode(src,dst): 仅拷贝权限,内容、组、用户均不变
import shutil shutil.copymode('f1.log', 'f2.log')
shutil.copystat(src,dst): 拷贝状态的信息,包括:mode bits,atime,mtime,flags
import shutil shutil.copystat('f1.log', 'f2.log')
shutil.copy(src,dst): 拷贝文件和权限
import shutil shutil.copy('f1.log', 'f2.log')
shutil.copy2(src,dst): 拷贝文件和状态信息
import shutil shutil.copy2('f1.log', 'f2.log')
shutil.copytree(src,det,symlinks=false,ignore=none): 递归的去拷贝文件
import shutil shutil.copytree('folder1', 'folder2', ignore=shutil.ignore_patterns('*.pyc', 'tmp*'))
shutil.rmtree(path[,ignore_errors[,onerror]]): 递归的去删除文件
import shutil shutil.rmtree('folder1')
shutil.move(src,dst): 递归的去移动文件(重命名)
import shutil shutil.move('folder1', 'folder3')
shutil.make_archive(base_name, format,...): 创建压缩包并返回文件路径,例如:zip、tar
import shutil z = shutil.make_archive('presly', 'gztar', root_dir='d:\软件下载')
shutil对压缩包的处理,也可调用zipfile或tarfile模块进行压缩
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python爬虫:Request Payload和Form Data的简单区别说明
浅谈Python中threading join和setDaemon用法及区别说明
Python3-异步进程回调函数(callback())介绍
python继承threading.Thread实现有返回值的子类实例
Python中使用threading.Event协调线程的运行详解
网友评论