How to check type of files without extensions in python? 不通过文件扩展名,怎样知道文件类型?


有一个命令 file 可以用

$ file fuck
fuck.png: PNG image data, 1122 x 750, 8-bit colormap, non-interlaced

python 中可以用 magic 或 filetype

参考链接
https://stackoverflow.com/questions/10937350/how-to-check-type-of-files-without-extensions-in-python