説明なし

zbar2.py 814B

    # -*- coding: utf-8 -*- from django.conf import settings from pywe_storage import RedisStorage from pywe_wxa_cv import cv_qrcode from utils.redis.connect import r WECHAT = settings.WECHAT def zbar2(path): wxcfg = WECHAT.get('MINIAPP', {}) appid = wxcfg.get('appID') secret = wxcfg.get('appsecret') # In[5]: test_zbar2() # {u'code_results': [{u'type_name': u'CODE_39', u'data': u'189415'}], u'img_size': {u'h': 1440, u'w': 1080}, u'errcode': 0, u'errmsg': u'ok'} img_infos = cv_qrcode(img_file_path=path, appid=appid, secret=secret, storage=RedisStorage(r)) code_results = img_infos.get('code_results', []) return [code.get('data', '').strip() for code in code_results] def test_zbar2(): # In[5]: test_zbar() # [u'189415'] print(zbar2(settings.TESTING_ZBAR))