common_qr.py 文件源码

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

项目:RaiWalletBot 作者: SergiySW 项目源码 文件源码
def account_by_qr(qr_file):
    qr = qrtools.QR()
    qr.decode(qr_file)
    # Try to increase contrast if not recognized
    if ('xrb_' not in qr.data):
        image = Image.open(qr_file)
        contrast = ImageEnhance.Contrast(image)
        image = contrast.enhance(7)
        image.save('{0}'.format(qr_file.replace('.jpg', '_.jpg')), 'JPEG')
        qr2 = qrtools.QR()
        qr2.decode('{0}'.format(qr_file.replace('.jpg', '_.jpg')))
        #print(qr2.data)
        qr = qr2
    returning = qr.data.replace('xrb:', '').replace('raiblocks://', '').replace('raiblocks:', '').split('?')
    # parsing amount
    if (len(returning) > 1):
        if ('amount=' in returning[1]):
            returning[1] = returning[1].replace('amount=', '')
            # don't use empty
            if (len(returning[1]) == 0):
                returning.pop()
        else:
            returning.pop()
    return returning
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号