Problem when unzipping file

Asked

Viewed 99 times

3

I have a zip that, inside it there are several files to be uncompressed. So far so good, I’m using the following method to twelve the same:?

with closing(z), zipfile.ZipFile(io.BytesIO(z.content)) as myzip:
                myzip.extractall(local_path)

However I came across the situation that inside the zip there is a file with Unicode can example:

- myfile.wav
- myfile2.wav
- my§ile.wav

How can I treat these files, to unzip them properly?

  • Not properly unpacking? What’s going on?

  • it cannot unzip, presents a Unicode error

  • Can post complete error, please?

1 answer

1


To work with Unicode characters, you need to add a functional comment type in the script header to avoid this error. I’m talking about the # -- coding: utf-8 --, used for this case. Here’s an example, for Python 2.7:

-- coding: utf-8 --

with closing(z), zipfile.Zipfile(io.Bytesio(z.content)) as myzip: myzip.extractall(local_path)

The sharp is not coming out to indicate that this is a comment and not the asterisks in the answer between the hyphens I do not know why when I write, but consider them in the writing of the program.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.