使用 python 获取文件类型

Posted on Posted in python

使用 python 获取文件类型

import fleep

with open("png_image", "rb") as file:
    info = fleep.get(file.read(128))

print(info.type)  # prints ['raster-image']
print(info.extension)  # prints ['png']
print(info.mime)  # prints ['image/png']

print(info.type_matches("raster-image"))  # prints True
print(info.extension_matches("gif"))  # prints False
print(info.mime_matches("image/png"))  # prints True
» 转载请注明来源:呢喃 » 使用 python 获取文件类型

Leave a Reply

Your email address will not be published. Required fields are marked *

two × three =