python script for generating QR code

Here is a Python script that you can use to create a QR code:

import qrcode

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

# Add data to the QR code
qr.add_data('https://www.example.com')

# Generate the QR code
qr.make(fit=True)

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

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


To use this script, you will need to have the qrcode library installed. You can install it using pip install qrcode.

This script creates a QR code that encodes the URL https://www.example.com. You can customize the QR code by changing the data that is encoded and the various parameters of the QRCode object. For example, you can change the version parameter to control the size of the QR code, or you can change the error_correction parameter to control the amount of error correction that is included in the QR code.

Once the QR code has been generated, the script creates an image from the QR code and saves it to a file called qr_code.png. You can customize the appearance of the QR code by changing the fill_color and back_color parameters of the make_image function.


Comments

Popular posts from this blog

SCI Recruitment 2016 for Assistant Manager Post

Grow your Art