shutil模块

it2022-05-05  121

shutil模块:高级的 文件、文件夹、压缩包 处理模块

# 基于路径的文件复制:shutil.copyfile('source_file', 'target_file')

# 基于流的文件复制:with open('source_file', 'rb') as r, open('target_file', 'wb') as w: shutil.copyfileobj(r, w)# 递归删除目标目录shutil.rmtree('target_folder')

# 文件移动shutil.move('old_file', 'new_file')

# 文件夹压缩shutil.make_archive('file_name', 'format', 'archive_path')

# 文件夹解压shutil.unpack_archive('unpack_file', 'unpack_name', 'format')

转载于:https://www.cnblogs.com/zhangdajin/p/11140966.html

相关资源:JAVA上百实例源码以及开源项目

最新回复(0)