DEV Community

loading...
Cover image for QR Code Generator and Reader in Python

QR Code Generator and Reader in Python

soniarpit profile image CodeSnail 🐌 Updated on ・1 min read

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 :)

Discussion (0)

pic
Editor guide