DEV Community

Cover image for QR Code Generator and Reader in Python
Arpit
Arpit

Posted on • Updated on

QR Code Generator and Reader in Python

QR code generator

import pyqrcode 
import png 
from PIL import Image 

s = "https://www.codesnail.com" 
url = pyqrcode.create(s) 

img = "codesnail-qr-code.png" 
url.png(img, scale=10) 

#opening image 
im=Image.open(img) 
im.show() 
Enter fullscreen mode Exit fullscreen mode

for installation guide: click me

QR code reader

from pyzbar.pyzbar import decode 
from PIL import Image 

d = decode(Image.open("codesnail-qr-code.png")) 
# print(d) 
print(d[0].data.decode()) 
Enter fullscreen mode Exit fullscreen mode

for installation guide: click me

Happy coding :)

Top comments (0)