QR Code Generator using Python

Note that you'll need to install the qrcode library first by running pip install qrcode.

!pip install qrcode

To create a QR code of a given link, you can use the qrcode library in Python. Here's an example of how you can do it:

import qrcode

def create_qr_code(link):
    # Create a QR code image
    qr = qrcode.QRCode(
        version=1,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=10,
        border=4,
    )

    # Add the link to the QR code data
    qr.add_data(link)
    qr.make(fit=True)

    # Create an image from the QR code data
    img = qr.make_image(fill_color="black", back_color="white")

    # Save the image to a file
    img.save("qr_code.png")

# Test the function with a sample link
create_qr_code("https://ajblogsprogramming.blogspot.com/")

This code will generate a QR code image file named "qr_code.png" that contains the link "https://ajblogsprogramming.blogspot.com/". You can then use this image file to display the QR code or print it out.

Output:











Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page