当前位置: 首页>>代码示例>>Python>>正文


Python ZipFile.readlines方法代码示例

本文整理汇总了Python中zipfile.ZipFile.readlines方法的典型用法代码示例。如果您正苦于以下问题:Python ZipFile.readlines方法的具体用法?Python ZipFile.readlines怎么用?Python ZipFile.readlines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zipfile.ZipFile的用法示例。


在下文中一共展示了ZipFile.readlines方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plugin_loaded

# 需要导入模块: from zipfile import ZipFile [as 别名]
# 或者: from zipfile.ZipFile import readlines [as 别名]
def plugin_loaded():

        from zipfile import ZipFile
        #
        # Is there an easier way to access files inside a .sublime-package file in Sublime Text 3?
        #

        # Find commitMessages file.
        package_path = path.join(sublime.installed_packages_path(), 'Commitment.sublime-package')

        if path.isfile(package_path):
            # Sublime Text 3 preferred way.
            messages_file = ZipFile(package_path).open(commitMessages)
            for line in messages_file.readlines():
                messages[md5(line).hexdigest()] = line.decode('utf-8')
        else:
            # Somebody unzipped this badass.
            messages_file = open(path.join(path.dirname(__file__), commitMessages), encoding='utf-8')
            for line in messages_file.readlines():
                messages[md5(line.encode('utf-8')).hexdigest()] = line

        CommitmentCommand.randomMessages = RandomCommitment(messages)
开发者ID:janraasch,项目名称:sublimetext-commitment,代码行数:24,代码来源:Commitment.py

示例2: _get_data_raw

# 需要导入模块: from zipfile import ZipFile [as 别名]
# 或者: from zipfile.ZipFile import readlines [as 别名]
    def _get_data_raw(self):
        """Download observations matching the time range.

        Returns a tuple with a string for the body, string for the headers,
        and a list of dates.
        """
        # Import need to be here so we can monkeypatch urlopen for testing and avoid
        # downloading live data for testing
        try:
            from urllib.request import urlopen
        except ImportError:
            from urllib2 import urlopen

        with closing(urlopen(self.ftpsite + self.site_id + self.suffix + '.zip')) as url:
            f = ZipFile(BytesIO(url.read()), 'r').open(self.site_id + self.suffix)

        lines = [line.decode('utf-8') for line in f.readlines()]

        body, header, dates_long, dates = self._select_date_range(lines)

        return body, header, dates_long, dates
开发者ID:Unidata,项目名称:siphon,代码行数:23,代码来源:igra2.py


注:本文中的zipfile.ZipFile.readlines方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。