python 打包成tar包
2024-08-26 09:54:42
def make_targz(output_filename, source_dir):
with tarfile.open(output_filename, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir))
def make_targz_one_by_one(output_filename, source_dir):
tar = tarfile.open(output_filename,"w:gz")
for root,dir,files in os.walk(source_dir):
for file in files:
pathfile = os.path.join(root, file)
tar.add(pathfile)
tar.close()
make_targz("test.tar.gz","a.txt") #or make_targz_one_by_one("test.tar.gz","a.txt")
最新文章
- java 数组中插入新的元素
- iOS深入学习(UITableView系列2:reloadData)
- Chrome 开发者工具有了设备模拟器
- 转:Bat命令学习
- WLS_Oracle Weblogic管理概述(概念)
- 【C#学习笔记】文本复制到粘贴板
- selenium python (三)鼠标事件
- 【CSS3】---结构性伪类选择器—nth-child(n)+nth-last-child(n)
- ZOJ 3817	Chinese Knot
- 1.tomcat部署项目的几种方式和weblogic部署方式及一点通讯
- 移动web:Tips消息弹出框
- 设置EditText控件中提示消息hint的字体颜色和大小
- windows下使用docker安装tensorflow
- dijit.byId(";grid";) is undefined
- CentOS7从U盘中拷贝文件
- netcore使用 jenkins + supervisor 实现standalone下多副本自动化发布
- Asp.Net SignalR Hub类中的操作详解
- 论文笔记---Deblurring Shaken and Partially Saturated Images
- 【BZOJ4316】小C的独立集(仙人掌,动态规划)
- 笔记本 原来win10系统改装win7系统遇到 invaid signature detected.check secure boot policy setup问题
热门文章
- 逻辑运算,&;,&;&;, |, ||, ^, !
- scipy模块
- collections模块(收藏)
- c语言中strcpy与strlen函数对字符串最后的'\0'的处理
- Asp.net Mvc5的认识
- 20154312 曾林 Exp8 web基础
- 无法在web服务器下启动调试
- Python:在windows下创建虚拟环境
- linux常用命令:sort 命令
- Linux基础命令---sort