解压乱码

with zipfile.ZipFile(my_zip) as zip_file:
for member in zip_file.namelist():
filename = os.path.basename(member)
print(filename)
try:
filename = filename.encode(‘cp437’).decode(‘gbk’)
except:
filename = filename.encode(‘utf-8’).decode(‘utf-8’)
print(filename)
# skip directories
if not filename:
continue

        # copy file (taken from zipfile's extract)
        source = zip_file.open(member)
        target = open(os.path.join(my_dir, filename), "wb")
        with source, target:
            shutil.copyfileobj(source, target)