在python有一个内置模块imghdr可以用来判断图片的真实类型。 如下代码: import imghdr imgType = imghdr.what(imageFile) 将会输出gif,png,jpeg等图片类型