python (jython) 归档库

发布于 2024-07-08 21:16:35 字数 203 浏览 3 评论 0原文

是否有一个简洁的归档库可以自动为您处理文件夹或目录的归档? 我正在使用 Jython,因此 Java 库也可供使用。 -更新- 我也在寻找时间戳归档。 即

archive-dir/2008/11/16/zipfilebypreference.zip

然后第二天再次调用它,它会创建另一个文件夹。 我确信互联网上有一些东西,谁知道呢?

Is there a neat archiving library that automatically handles archiving a folder or directories for you out there?
I am using Jython, so Java libs are also open for use.
-UPDATE-
Also Im looking for timestamp archiving. ie

archive-dir/2008/11/16/zipfilebypreference.zip

then the next day call it again and it creates another folder.
Im sure there is something out there on the internet, who knows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别挽留 2024-07-15 21:16:35

您可以

import  javax.servlet.http.HttpServlet

import  cStringIO
import  gzip
import  string

def compressBuf(buf):
    zbuf = cStringIO.StringIO()
    zfile = gzip.GzipFile(mode = 'wb',  fileobj = zbuf, compresslevel = 6)
    zfile.write(buf)
    zfile.close()
    return zbuf.getvalue()
  • 或直接使用 java.util.zip,如下所示此处,对于一个文件,或对于所有目录内容。

You have either the:

 

import  javax.servlet.http.HttpServlet

import  cStringIO
import  gzip
import  string

def compressBuf(buf):
    zbuf = cStringIO.StringIO()
    zfile = gzip.GzipFile(mode = 'wb',  fileobj = zbuf, compresslevel = 6)
    zfile.write(buf)
    zfile.close()
    return zbuf.getvalue()
  • or the direct used of java.util.zip as illustrated here, for one file, or for a all directory content.
温柔少女心 2024-07-15 21:16:35

你可以使用java.util.zip,当我使用Jython时,python中内置的zip库不起作用

You can use java.util.zip, when I was using Jython the built in zip library in python didn't work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文