包方法:
GzipFile open gzip_file = gzip.open('B5-H.pickle.gz') >>> type(tar_file) <class 'gzip.GzipFile'> tar_file1 = gzip.GzipFile('testtar.tar') >>> type(tar_file1) <class 'gzip.GzipFile'> compress s_in = b"Lots of content here" s_out = gzip.compress(s_in) >>> s_out b'\x1f\x8b\x08\x00\xeb\x01\x1bd\x02\xff\xf3\xc9/)V\xc8OSH\xce\xcf+I\xcd+Q\xc8H-J\x05\x00~u \x8e\x14\x00\x00\x00' decompress >>> s_out = gzip.decompress(s_out) >>> s_out b'Lots of content here'
GzipFile类方法
属性 name mtime closed 方法 tell 当前指针位置 rewind 重置到0开始的位置 seek Change stream position truncate Truncate file to size bytes peek peek(n) 可在不移动文件指针的情况下读取n个未压缩字节 flush Flush write buffers, if applicable 'close', 'read', 'readline', 'readlines', 'write', 'writelines'
标签:file,tar,详解,模块,gzip,x00,GzipFile,out From: https://www.cnblogs.com/hushaojun/p/17245539.html