Python uncompressed file release question.

Asked 2 weeks ago, Updated 2 weeks ago, 2 views

Hello, everyone

There was a problem when I created a data folder in the same location as the py file and tried to decompress all the compressed files in the data folder.

First of all, the coding I did is

import zipfile

file_path = './data/'

output_unzip = zipfile.ZipFile('./data/.zip', 'r') 



I did it like this I think it'll work, but there's a path error.

FileNotFoundError: [Errno 2] No such file or directory: './data/.zip' 

Is there any solution?


2022-09-20 11:01

1 Answers

If you look at the path of the error message, you can see why. There are only paths and extensions, but there are no important file names. The path ./data/ does not contain a file named .zip so I think it is an error.

In addition, to decompress all files in the data folder, you must take the names of all .zip files and repeat them so that they can be extracted from one file to another. I think this code will only run once in the specified file.

2022-09-20 11:01

If you have any answers or tips

© 2022 pinfo. All rights reserved.