'Python QRCODE save to folder

How can I save img to a specific folder? I tried img.save(path, format="PNG") but it doesn't work.

def generate_qr_code(url):
    qr = qrcode.QRCode(
        version=1,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=15,
        border=5,
    )
    qr.add_data(url)
    path = ('./static/image')
    qr.make(fit=True)
    img = qr.make_image(fill='black', back_color='white')
    temp = BytesIO()
    img.save(path, format="PNG")
    qr_img = base64.b64encode(temp.getvalue())
    return qr_img


Solution 1:[1]

You Can Use path = ('absolute path where you want to save your QR Code File')

i.e - path = ('C:\\Users\\Omii\\Desktop\\QR.png')

Use Always Double Backslash

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Omii