-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
29 lines (23 loc) · 712 Bytes
/
code.py
File metadata and controls
29 lines (23 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import code
def generate_qr_code(data):
"""Generates a QR code image from the given data.
Args:
data: The data to be encoded in the QR code.
Returns:
The generated QR code image.
"""
qr = code.QRCode(
version=1,
error_correction=code.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
return img
if __name__ == "__main__":
data = input("Enter the data to encode in the QR code: ")
qr_code_image = generate_qr_code(data)
qr_code_image.save("qr_code.png")
print("QR code generated and saved as qr_code.png")