qrcode python
To generate a QR code using Python, you can use the qrcode library. You can install it using the following command:
pip install qrcode
Here's an example of how to generate a QR code:
import qrcode
# Text or data to be encoded in the QR code
data = "Hello, World!"
# Generate QR code
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(data)
qr.make(fit=True)
# Create an image from the QR code
image = qr.make_image(fill_color="black", back_color="white")
# Save the image or display it
image.save("qrcode.png")
image.show()
In this example, the QR code is generated with the text "Hello, World!" and saved as "qrcode.png". You can change the data variable to encode any text or data you want.
原文地址: https://www.cveoy.top/t/topic/i7eu 著作权归作者所有。请勿转载和采集!