xxxxxxxxxx
# Import QRCode from pyqrcode
import pyqrcode
import png
from pyqrcode import QRCode
# String which represents the QR code
s = "www.codingforfree.com"
# Generate QR code
url = pyqrcode.create(s)
# Create and save the svg file naming "myqr.svg"
url.svg("myqr.svg", scale = 8)
# Create and save the png file naming "myqr.png"
url.png('myqr.png', scale = 6)
xxxxxxxxxx
import os
import qrcode
img = qrcode.make("https://Your-URL-here")
img.save("qr.png", "PNG")
os.system("display qr.png")
xxxxxxxxxx
# Importing library
import qrcode
# Data to be encoded
data = 'www.google.com'
# Encoding data using make() function
img = qrcode.make(data)
# Saving as an image file
img.save('MyQRCode1.png')
xxxxxxxxxx
# pip install pyqrcode
#pip install pypng
import pyqrcode
import png
from pyqrcode import QRCode
string = 'www.google.com'
url = pyqrcode.create(string)
url.svg("myqr.svg" , scale = 8)
url.png("myqr.png" , scale = 6)
xxxxxxxxxx
import qrcode
img=qrcode.make("message")
img.save("pic.png") //save the qrcode photo as pic.png
xxxxxxxxxx
#Install modules -> qrcode , pillow
import qrcode
import PIL
qr = qrcode.QRCode(version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=100, border=1)
qr.add_data("https://rafiulislamrohan.github.io/rafiulislam")
qr.make(fit=True)
img = qr.make_image(fill_color="#90EE90", back_color="black")
img.save("Rafiul_Islam.png")
xxxxxxxxxx
import qrcode
img = qrcode.make('Some data here')
type(img) # qrcode.image.pil.PilImage
img.save("some_file.png")
xxxxxxxxxx
import tempfile
import segno
import xlwings as xw
def main():
book = xw.Book.caller()
sheet = xw.sheets[0]
# Start at the selected cell
start_cell = book.app.selection
if start_cell.value is None:
raise TypeError('Please select a cell with a value!')
urls = start_cell.options(expand='down', ndim=1).value
# Loop through each URL and generate the QR code
for ix, url in enumerate(urls):
# Generate the QR code
qr = segno.make(url)
with tempfile.TemporaryDirectory() as td:
# Save the QR code as a temporary svg file. If you are on macOS, use pdf
# instead and if you don't have Microsoft 365, you may have to use png
filepath = f'{td}/qr.svg'
qr.save(filepath, scale=5, border=0, finder_dark='#15a43a')
# Insert the QR code to the right of the URL
destination_cell = start_cell.offset(row_offset=ix, column_offset=1)
sheet.pictures.add(filepath,
left=destination_cell.left,
top=destination_cell.top)
xxxxxxxxxx
import pyqrcode
import png
from PIL import Image
s = "https://python.plainenglish.io/" # url to open after scanning qr code
url = pyqrcode.create(s) # creating qr code
img = "python-in-plain-english.png" # name of image
url.png(img, scale=10) # saving image as png
im=Image.open(img) # opening image
im.show()