DEV Community

Cover image for Generate QR codes in Python
petercour
petercour

Posted on

16 6

Generate QR codes in Python

QR code a type of matrix barcode first designed in 1994 for the automotive industry in Japan. These days it's used in many places like banking, cryptocurrency, advertisements and more.

Did you know you can generate these codes with Python? You should know the Python programming language. But even without to much practice, you can generate them.

Install the qrcode module

pip install qrcode
Enter fullscreen mode Exit fullscreen mode

Then you can load it in Python

#!/usr/bin/python3
import qrcode
img = qrcode.make('hello world')
img.save('test.png')
Enter fullscreen mode Exit fullscreen mode

This will output the QR code as an image (test.png).

So it's that easy. How much data can you store on a QR code?

According to stackoverflow

QR codes have three parameters: 
Datatype, size (number of 'pixels') and error correction level. 
How much information can be stored there also depends on these   
parameters. 
Enter fullscreen mode Exit fullscreen mode
  • Numeric only Max. 7,089 characters
  • Alphanumeric Max. 4,296 characters
  • Binary/byte Max. 2,953 characters (8-bit bytes)

You may be able to zip your data and bypass this limit to some extend.

Related links:

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (1)

Collapse
 
ameek profile image
ameekaziz

Thanks, great for me as a head strat!

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more