Qr code using python
To generate a QR code using Python, you can use the qrcode library. Here's an example code snippet:
python
Copy code
import qrcode
# Create a QR code instance
qr = qrcode.QRCode(version=1, box_size=10, border=5)
# Add data to the QR code
data = "https://www.example.com"
qr.add_data(data)
# Compile 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
img.save("example_qrcode.png")
This code creates a QR code instance, adds data to it, compiles the QR code, creates an image from the QR code, and saves the image as a PNG file named example_qrcode.png.
You can adjust the version, box_size, and border parameters to change the size and complexity of the QR code. You can also modify the fill_color and back_color parameters to change the colors of the QR code
Comments
Post a Comment