import struct data = open('myfile.zip', 'rb').read() start = 0 for i in range(3): # show the first 3 file headers start += 14 fields = struct.unpack('LLLHH', data[start:start+16]) crc32, comp_size, uncomp_size, filenamesize, extra_size = fields start += 16 filename = data[start:start+filenamesize] start += filenamesize extra = data[start:start+extra_size] print filename, hex(crc32), comp_size, uncomp_size start += extra_size + comp_size # skip to the next header
收藏
0人收藏
- 2017-03-20 12:05:06Open a text file and write a line of text by 风云轩
- 2017-03-11 19:36:33Open a file and read char by char by 阿明娃儿
- 2016-01-01 13:50:06Looping through the file, line by line. by xwz
- 2016-03-06 20:01:32Handle File reading Exception by 西国の海妖
- 2016-12-24 10:24:24Reading a file: readlines and xreadlines by 张宋付
- 2016-11-27 10:13:11Reading the newly created file. by 山药
- 2016-01-02 10:12:28Copy file and move dir by Solon.Ring
- 2016-11-27 14:14:10File readline() by 张宋付
- 2013-06-04 13:43:27web.py中自定义jinja2模块 by 赵小全
- 2015-02-23 09:40:23ubuntu安装python3的python-pip by 甄码农
- 2016-08-19 15:46:08Working with Directories by 西国の海妖
相关聚客文章
- 通过 shell 执行 python 报错: No such file or directory
- Fastest way to unzip a zip file in Python
- Python2 print不换行
- Python 不是 C
- 用Python Requests抓取知乎用户信息
- 有趣的 Python 代码片断 - 1
- sync_file_range - sync a file segment with disk (N
- python pdb 简单使用
- 一个简单的python小程序——使用douban API通过ISBN查询书籍信息
- Python源码阅读-内存管理机制(一)
- 其实python可以这样学7-python对linux说hello
- Effective Python 心得筆記: Item 26