【文件属性】:
文件名称:shell相关模块 subprocess模块
文件大小:107KB
文件格式:PDF
更新时间:2020-12-21 10:46:56
c ce oc
系统管理模块
shutil模块
复制和移动
1.shutil.copyfileobj(fsrc,fdst[length])
将类似文件的对象fsrc的内容复制到类似文件的对象fdst
2.shutil.copyfile(src,dst, *, follow_symlinks=True)
将名为src的文件的内容(无元数据)复制到名为dst的文件,然后返回dst
# 练习
import shutil
f1 = open('/etc/hosts', 'rb')
f2 = open('/tmp/zhuji', 'wb')
dir(shutil)
shutil.copyfileobj(f1, f2)