使用Python库:http://github.com/ahupp/python-magic
安装:
pip install python-magic
- 识别单个文件
import magic
file_path = "文件路径"
M = magic.Magic(magic_file="magic.mgc")
file_type = M.from_file(file_path)
使用Python库:http://github.com/ahupp/python-magic
安装:
pip install python-magic
import magic
file_path = "文件路径"
M = magic.Magic(magic_file="magic.mgc")
file_type = M.from_file(file_path)