本文主要是介绍python批量生成二维码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
python批量生成二维码
安装相关库(注意要按顺序安装)
pip install pillow
pip install qrcode
代码:
import qrcode
import xlrddef getInfo():try:data = xlrd.open_workbook(r"C:\Users\USER\Desktop\BIAO.xlsx")sheetname = "Sheet1"table = data.sheet_by_name(sheetname)col_values = table.col_values(0)return col_valuesexcept Exception as e:print(e)def getImage():machList = getInfo()s = 0for machCode in machList:# 要放在循环里,否则 qr.add_data(filename) 会一直累加qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=1) filename = "AAA-MA:" + machCodeqr.add_data(filename)qr.make(fit=True)img = qr.make_image()file = "image/{0}.png".format(machCode)img.save(file)s += 1getImage()
这篇关于python批量生成二维码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!