<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    xylz,imxylz

    關(guān)注后端架構(gòu)、中間件、分布式和并發(fā)編程

       :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      111 隨筆 :: 10 文章 :: 2680 評論 :: 0 Trackbacks
    9-22.

    ZIP Archive Files. The unzip -l command to dump the contents of ZIP archive is boring. Create a Python script called lszip.py that gives additional information such as: the compressed file size, the compressed percentage of each file (by comparing the original and compressed file sizes), and a full time.ctime() timestamp instead of the unzip output (of just the date and HH:MM). Hint: The date_time attribute of an archived file does not contain enough information to feed to time.mktime()... it is up to you!

    #!/usr/bin/env python
    #
    -*- coding:utf-8 -*-
    #
    $Id: p0922.py 168 2010-06-29 06:34:01Z xylz $

    '''
    This is a 'python' study plan for xylz.
    Copyright (C)2010 xylz (www.imxylz.info)
    '''

    import zipfile
    import os
    import datetime


    def list (zip_file,files):
        
    print "list %s files from %s" % (len(files) if files!='*' else 'total',zip_file)
        
        f_in 
    = zipfile.ZipFile(zip_file, 'r')
        infoes 
    = None
        
    if '*' == files:
            infoes 
    = f_in.infolist()
        
    else:
            infoes 
    = []
            
    for f in files:
                infoes.append(f_in.getinfo(f))
        
    print "filename:\t\tuncompress\tcompress\tpercent\tcreatetime"
        
    print "-----------------------------------------"
        total_usize,total_csize 
    = (0,0)
        
    for info in infoes:
            (year, month, day, hour, minute, second) 
    = info.date_time
            dtime 
    = datetime.datetime(year, month, day, hour, minute, second)
            filename,usize,csize 
    = info.filename,info.file_size,info.compress_size 
            
    print "%s:\t\t%d\t%d\t%d%%\t%s" % (filename,usize,csize,(csize*100/(usize+0.01)),dtime.ctime())
            total_usize 
    += usize
            total_csize 
    += csize
        f_in.close()

        
    print "-----------------------------------------"
        
    print "compressed size %d bytes, uncompressed size %d bytes, %d%%" % (total_csize,total_usize,(total_csize*100/total_usize))
                
            

    if __name__ == '__main__':
        
    import sys
        
    if len(sys.argv)<2:
            
    print "List files in zip file"
            
    print "Usage: %s <zipfile> [files]" % (sys.argv[0],)
            sys.exit(0)
        zip_file 
    = sys.argv[1]
        files 
    = '*'
        
    if len(sys.argv)>2:
            files 
    = []
            
    for f in sys.argv[2:]:
                files.append(f)
        list(zip_file,files)


    ©2009-2014 IMXYLZ |求賢若渴
    posted on 2010-06-29 14:56 imxylz 閱讀(16879) 評論(0)  編輯  收藏 所屬分類: Python

    ©2009-2014 IMXYLZ
    主站蜘蛛池模板: 成人网站免费大全日韩国产| 亚洲日韩精品无码AV海量| 成在线人直播免费视频| 日韩成人免费在线| 亚洲熟女综合色一区二区三区 | 最近2019中文字幕免费看最新| 亚洲欧洲精品久久| 四虎在线免费视频| 日韩亚洲不卡在线视频中文字幕在线观看 | baoyu777永久免费视频 | 亚洲av日韩av欧v在线天堂| 疯狂做受xxxx高潮视频免费| 国产高清免费在线| 免费人成视频在线播放| 亚洲欧洲日产国码一级毛片 | 2021国内精品久久久久精免费| 亚洲色成人网一二三区| 波多野结衣在线免费视频| 亚洲午夜福利在线视频| 四虎影在线永久免费观看| 国产成人无码免费网站| 无码专区—VA亚洲V天堂| 成人免费观看一区二区| 亚洲爆乳无码专区www| 亚洲精品尤物yw在线影院| 国产午夜无码精品免费看| 亚洲va在线va天堂va手机| 国产人成免费视频| 青柠影视在线观看免费| 亚洲最新黄色网址| 免费在线精品视频| 四虎成人精品永久免费AV| 亚洲精品理论电影在线观看| 亚洲伊人成无码综合网| 一级毛片在线完整免费观看| 自拍日韩亚洲一区在线| 在线免费不卡视频| 一级做a爰黑人又硬又粗免费看51社区国产精品视 | 亚洲国产成人AV在线播放| 亚洲日韩小电影在线观看| 97性无码区免费|