Python shutil模块

copy(src, dst)
Copy data and mode bits ("cp src dst").

The destination may be a directory.

copy2(src, dst)
Copy data and all stat info ("cp -p src dst").

The destination may be a directory.

copyfile(src, dst)
Copy data from src to dst

copyfileobj(fsrc, fdst, length=16384)
copy data from file-like object fsrc to file-like object fdst

copymode(src, dst)
Copy mode bits from src to dst

copystat(src, dst)
Copy all stat info (mode bits, atime and mtime) from src to dst

copytree(src, dst, symlinks=False)
Recursively copy a directory tree using copy2().

The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.

If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the contents of the files pointed to by symbolic
links are copied.

XXX Consider this example code rather than the ultimate tool.

move(src, dst)
Recursively move a file or directory to another location.

If the destination is on our current filesystem, then simply use
rename. Otherwise, copy src to the dst and then remove src.
A lot more could be done here... A look at a mv.c shows a lot of
the issues this implementation glosses over.

rmtree(path, ignore_errors=False, οnerrοr=None)
Recursively delete a directory tree.

If ignore_errors is set, errors are ignored; otherwise, if onerror
is set, it is called to handle the error with arguments (func,
path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
path is the argument to that function that caused it to fail; and
exc_info is a tuple returned by sys.exc_info(). If ignore_errors
is false and onerror is None, an exception is raised.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值