首页 > 代码库 > python 生成二维码

python 生成二维码

#coding:utf8try:    import qrcodeexcept ImportError:    qrcode = Noneclass MakeQr:	def onUseQrcode(self, value):	        qr = qrcode.QRCode(version=1, box_size=10, border=4)	        qr.add_data(value)	        qr.make(fit=True)	        x = qr.make_image()	  	        img_file = open("1.jpg", ‘wb‘)	        x.save(img_file, ‘JPEG‘)	        img_file.close()	        print ‘ok‘if __name__ == ‘__main__‘:	value = "http://www.baidu.com"	makeQr = MakeQr()	makeQr.onUseQrcode(value)