read_from_zip.py

来自「学习Pyhton脚本的源代码」· Python 代码 · 共 18 行

PY
18 行
字号
#------------------------------------------------------------------------------
#           Name: read_from_zip.py
#         Author: Kevin Harris (kevin@codesampler.com)
#  Last Modified: 02/13/04
#    Description: This Python script demonstrates how to use zipfile to read
#                 from a zipped archive.
#------------------------------------------------------------------------------

import zipfile

myZipFile = zipfile.ZipFile( "test.zip", "r" )

for fileName in myZipFile.namelist():
    data = myZipFile.read(fileName)
    print fileName, len(data), repr(data[:50])

raw_input( '\n\nPress Enter to exit...' )

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?