Why does zipfile.is_zipfile return True in an xlsx file?

I use is_zipfileto check if this is a zip file before extracting it. But the method returns True in the excel file from the StringIO object. I am using Python 2.7. Does anyone know how to fix this? Can I use it is_zipfiile? Thanks.

+4
source share
2 answers

Quote from Microsoft xlsx Structure doc ,

Workbook data is contained in an email package that complies with the Open Packaging Agreement

, .xlsx zip . zip , if,

if os.path.splitext(filename)[1] != ".xlsx" and zipfile.is_file(filename):
+2
+3

Source: https://habr.com/ru/post/1530532/


All Articles