deathbycaptcha.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:deathbycaptcha 作者: hideki-saito 项目源码 文件源码
def _load_image(captcha):
    if hasattr(captcha, 'read'):
        img = captcha.read()
    elif type(captcha) == bytearray:
        img = captcha
    else:
        img = ''
        try:
            captcha_file = open(captcha, 'rb')
        except Exception:
            raise
        else:
            img = captcha_file.read()
            captcha_file.close()
    if not len(img):
        raise ValueError('CAPTCHA image is empty')
    elif imghdr.what(None, img) is None:
        raise TypeError('Unknown CAPTCHA image type')
    else:
        return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号