1. 程式人生 > >python_使用qrcode生成二維碼

python_使用qrcode生成二維碼

文字 qrc port span def style text class else

1.功能

使用qrcode生成二維碼

2.代碼

#生成二維碼:
import qrcode

#根據url生成二維碼
def qrcodeWithUrl(url):
    img = qrcode.make(url)
    savePath = "1.png"
    img.save(savePath)

#根據輸入的文字生成二維碼
def qrcodeWithText(text):
    img = qrcode.make(text)
    savePath = "2.png"
    img.save(savePath)

#輸入一句話
content = input("
請輸入一名話:") if "http" in content: qrcodeWithUrl(content) else: qrcodeWithText(content) print("二維碼已生成完畢,請查看!")

python_使用qrcode生成二維碼