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")

最新文章

  1. java 数组中插入新的元素
  2. iOS深入学习(UITableView系列2:reloadData)
  3. Chrome 开发者工具有了设备模拟器
  4. 转:Bat命令学习
  5. WLS_Oracle Weblogic管理概述(概念)
  6. 【C#学习笔记】文本复制到粘贴板
  7. selenium python (三)鼠标事件
  8. 【CSS3】---结构性伪类选择器—nth-child(n)+nth-last-child(n)
  9. ZOJ 3817 Chinese Knot
  10. 1.tomcat部署项目的几种方式和weblogic部署方式及一点通讯
  11. 移动web:Tips消息弹出框
  12. 设置EditText控件中提示消息hint的字体颜色和大小
  13. windows下使用docker安装tensorflow
  14. dijit.byId("grid") is undefined
  15. CentOS7从U盘中拷贝文件
  16. netcore使用 jenkins + supervisor 实现standalone下多副本自动化发布
  17. Asp.Net SignalR Hub类中的操作详解
  18. 论文笔记---Deblurring Shaken and Partially Saturated Images
  19. 【BZOJ4316】小C的独立集(仙人掌,动态规划)
  20. 笔记本 原来win10系统改装win7系统遇到 invaid signature detected.check secure boot policy setup问题

热门文章

  1. 逻辑运算,&,&&, |, ||, ^, !
  2. scipy模块
  3. collections模块(收藏)
  4. c语言中strcpy与strlen函数对字符串最后的'\0'的处理
  5. Asp.net Mvc5的认识
  6. 20154312 曾林 Exp8 web基础
  7. 无法在web服务器下启动调试
  8. Python:在windows下创建虚拟环境
  9. linux常用命令:sort 命令
  10. Linux基础命令---sort