zbar 能够解析 qrcodepython
不过安装过程但是艰辛git
本地开发用mac,生产服务器用ubuntu。安装方式不一样。整理出如下安装方式github
#!/usr/bin/python import zbar from PIL import Image import urllib import cStringIO #图片地址替换成你的qrcode图片地址 URL = ('http://example.qiniudn.com/msgimagepicc4WJ-4iTk8.jpeg') # create a reader scanner = zbar.ImageScanner() # configure the reader scanner.parse_config('enable') # obtain image data imgfile = cStringIO.StringIO(urllib.urlopen(URL).read()) pil = Image.open(imgfile).convert('L') width, height = pil.size raw = pil.tostring() # wrap image data image = zbar.Image(width, height, 'Y800', raw) # scan the image for barcodes scanner.scan(image) # extract results for symbol in image: # do something useful with results print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data # clean up del(image)