A minimal command-line tool that converts any URL into a QR code image. The script uses the qrcode Python library to generate the QR and saves it as a PNG file with a user-specified filename.
- Converts any URL into a QR code.
- Saves output as a PNG file.
- Automatically adds
.pngif the user doesn’t include it. - Simple, clean, and beginner-friendly.
-
Prompts the user for:
- A URL
- The file name to save the QR code
-
Ensures the filename ends with
.png:if not(filename.endswith(".png")): filename += ".png"
-
Generates the QR using:
img = qrcode.make(url)
-
Saves the image to disk:
img.save(filename)
pip install qrcode[pil]Run the script:
python main.pyExample interaction:
Enter your url: https://example.com
Filename you want to save it as: myqr
Output generated:
myqr.png
- Python 3.x
qrcodelibrary- Pillow (installed automatically with
qrcode[pil])