Forum Discussion
How can I create a QR code for my website for free?
To generate a QR code for a website using Python with the qrcode library, you can follow these straightforward steps. Here's a simple example:
Step-by-step guide to make a QR code for a Website:
1. Install the qrcode library (if you haven't already):
pip install qrcode[pil]
2. Create a Python script to generate the QR code:
import qrcode
# The URL of the website you want to encode
website _ url = 'http//www.example.com'
# Create a QRCode object
qr = qrcode.QRCode(
version=1, # controls the size of the QR code
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
# Add the data to the QR code
qr .adddata(website url)
qr .make(fit=True)
# Create an image from the QR Code
img = qr .make_image(fill_color='black', back_color='white')
# Save the image
img .save('website_qr .png')
print("QR code for a website has been generated and saved as 'website_qr .png'.")
Explanation:
"make a QR code for a website" appears in the content of the narration.
Replace 'http//www.example.com' with your actual website URL.
The generated QR code image will be saved as 'website_qr. png'.