工作需要,网上找了很多生成接口都不理想,各种限制,还是自己写个吧,自己动手丰衣足食
首先安装qrcode 包
install qrcode
pip install qrcode
代码实现
sources
import qrcode
import os
pathfile="文件路径"
def QrCodeBatch(pathfile,pathdir):
file = open(pathfile)
readlines = file.readlines()
i=0
for readline in readlines:
qr.add_data(readline.strip())
qr.make(fit=True)
img = qr.make_image()
filename=readline.strip()+'.png'
readline=''
img.save(filename)
qr.clear()
i=i+1
print('done No. '+str(i))
print('sucess '+str(i))
file.close()
后续开发
命令行自己用着方便,同事计算机小白,所以后面考虑加个UI界面方便同事操作
本文介绍了一种使用Python批量生成二维码的方法,通过安装qrcode包并编写简单代码,实现了从文件读取数据并为每一项生成对应二维码的功能,最后探讨了增加UI界面以方便非技术人员使用的可能性。
2012

被折叠的 条评论
为什么被折叠?



