类型检测
项目描述
一个类型检测库。
特性
检测类型齐全,需要检测的类型,中的检测类型,直接写新模块。
主要给予逆向工程方向的检测类型,也支持一般类型的检测。
安装
❯ pip install pyftype
❯ pyftype -h
usage: pyftype [-h] [-V] p
positional arguments:
p path
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
❯ pyftype Makefile
File extension: txt
File MIME type: application/txt
翻译
import pyftype
# file
f = open(path, "rb")
data = f.read()
kind = pyftype.guess(data)
# path
kind = pyftype.guess(path)
# bytes
buf = bytearray([0xFF, 0xD8, 0xFF, 0x00, 0x08])
kind = pyftype.guess(buf)
具体参考示例目录