imghdr --- 判断图像类型
文章目录
def is_image(file_path):
"""
判断时候是否为图片
:param file_path:文件路径
如果是 return True
否则 return False
"""
try:
img_type = imghdr.what(file_path)
return img_type is not None
except (IOError, OSError):
return False

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论