Python - mechanism to identify compressed file type and uncompress

前端 未结 7 2075
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 17:35

A compressed file can be classified into below logical groups
a. The operating system which you are working on (*ix, Win) etc.
b. Different types of compression algo

7条回答
  •  北海茫月
    2020-12-12 18:11

    "a" is completely false.

    "b" can be easily interpreted badly, as ".zip" doesn't mean the file is actually a zip file. It could be a JPEG with zip extension (for confusing purposes, if you want).

    You actually need to check if the data inside the file matches the data expected to have by it's extension. Also have a look at magic byte.

提交回复
热议问题