import qrcode
import os
def create_qrcode(data):
filename = os.path.join('./', 'xxx', '.png')
params = {
'version': 4,
#L:7% M:15% Q:25% H:30%
'error_correction': qrcode.constants.ERROR_CORRECT_M,
'box_size': 10,
'border': 2
}
# 配置相關參數
qr = qrcode.QRCode(**params)
# 添加信息, data爲str格式
qr.add_data(data)
# 創建code生成器
qr.make(fit=True)
# 創建生成二維碼
img = qrc.make_image(fill_color="black", back_color="white")
# 二維碼保存
# img.save(srcname)
##
icon = image.open(logo)
# img.paste(icon,(w, h), icon)
# 二維碼保存
# img.save(srcname)