Get file names of tarred folder contents in Python
问题 I have a compressed folder called gziptest.tar.gz which contains several plaintext files. I'd like to be able to get the filenames and corresponding contents of the files, but the examples of usage for the gzip library don't cover this. The following code: import gzip in_f = gzip.open('/home/cholloway/gziptest.tar.gz') print in_f.read() produces the output: gzip test/file2000664 001750 001750 00000000016 12621163624 015761 0ustar00chollowaycholloway000000 000000 I like apples gzip test