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

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

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

    xylz,imxylz

    關注后端架構、中間件、分布式和并發編程

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      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
    主站蜘蛛池模板: 亚洲国产日韩在线一区| 亚洲va久久久久| 久久精品亚洲中文字幕无码麻豆| 手机永久免费的AV在线电影网| 成年男女免费视频网站| 免费一级特黄特色大片| 久久精品国产亚洲AV麻豆网站| 国产美女做a免费视频软件| 永久免费不卡在线观看黄网站| 亚洲欧洲日韩国产一区二区三区| 亚洲国产电影av在线网址| 免费看男人j放进女人j免费看| 中文字幕亚洲综合久久综合| 亚洲中文字幕不卡无码| 99在线视频免费观看视频| 精品熟女少妇aⅴ免费久久| 亚洲制服丝袜中文字幕| 亚洲精品无码鲁网中文电影| 午夜视频免费成人| 国产成人一区二区三区视频免费 | 亚洲一区二区三区国产精品无码| 亚洲av无码乱码在线观看野外 | 国产v精品成人免费视频400条| 狠狠躁狠狠爱免费视频无码| 亚洲 日韩 色 图网站| 亚洲VA中文字幕不卡无码| 四虎永久在线精品免费影视| 成人a毛片免费视频观看| 亚洲国产精品免费在线观看| 亚洲日韩欧洲乱码AV夜夜摸| 国产免费看插插插视频| 免费视频专区一国产盗摄| 久久综合亚洲色hezyo| 亚洲精品亚洲人成在线观看麻豆| 亚洲伊人色欲综合网| 免费永久国产在线视频| 大学生一级特黄的免费大片视频 | 国产三级在线观看免费| 精品无码专区亚洲| 国产乱子影视频上线免费观看| 好猛好深好爽好硬免费视频|