根据文本数据列表,批量生成二维码的Python程序。本示例源文件PL_XLD_CODE.txt生成目标文件在同一目录下:
运行过程:
def make_qr_code(content, save_path=None): """ Generate QR Code by given params :param content: The content encoded in QR Code :param save_path: The path where the generated QR Code image will be saved in. If the path is not given the image will be opened by default. """ qr_code_maker = qrcode.QRCode(version=2, error_correction=qrcode.constants.ERROR_CORRECT_M, box_size=4, border=1, ) qr_code_maker.add_data(data=content) qr_code_maker.make(fit=True) img = qr_code_maker.make_image(fill_color="black", back_color="white") if save_path: img.save(save_path) else: img.show()
另外还有带ICON的,详见源文件。
评论