#coding:utf8
try:
import qrcode
except ImportError:
qrcode = None class 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)