Decompress bz2 files
问题 I would like to decompress the files in different directories which are in different routes. And codes as below and the error is invalid data stream. Please help me out. Thank you so much. import sys import os import bz2 from bz2 import decompress path = "Dir" for(dirpath,dirnames,files)in os.walk(path): for file in files: filepath = os.path.join(dirpath,filename) newfile = bz2.decompress(file) newfilepath = os.path.join(dirpath,newfile) 回答1: bz2.compress/decompress work with binary data: >>>