代码之家  ›  专栏  ›  技术社区  ›  Gerhard

从Ruby中的zip文件读取文件注释

  •  3
  • Gerhard  · 技术社区  · 15 年前

    我正在做 Python challenge 红宝石。我需要从压缩文件中读取文件内容和注释。内容与 RubyZip 但是我不能把评论说出来。有什么想法吗?

    2 回复  |  直到 15 年前
        1
  •  5
  •   phloopy    15 年前

    实际上,你会想要每个文件的评论,我很难找到 documentation on . 下面是一个如何从文件中获取注释的示例。

    require 'zip/zip'
    
    Zip::ZipFile.open("6.zip") do |zipfile|
      p zipfile.get_entry("90052.txt").comment
    end
    
        2
  •  6
  •   mikej heading_to_tahiti    15 年前

    根据文件,一个 RubyZip ZipFile 类有一个 comment 属性,返回zip文件的注释(如果有)。

    例如

    require 'zip/zip'
    
    Zip::ZipFile.open('zip_with_comment.zip') do |zipfile|
      puts zipfile.comment
    end