# @Software : Window10 + Python3.6 + PyCharm import qrcode import os import sys import time QRImagePath = os.getcwd() + '/qrcode.png' qr =qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=2, ) #设置图片格式 data=input("请输入你想保存的信息: ") #运行时输入数据 qr.add_data(data) qr.make(fit=True) img = qr.make_image() img.save('qrcode.png') #生成图片 if sys.platform.find('darwin') >= 0: os.system('open %s' % QRImagePath) elif sys.platform.find('linux') >= 0: os.system('xdg-open %s' % QRImagePath) else: os.system('call %s' % QRImagePath) time.sleep(5) #间隔5个单位 os.remove(QRImagePath) #删除图片
如何用python生成一张二维码图片
- THE END -
本文由 @晓说杂谈 修订发布于 2023-07-30
本文来自投稿,不代表本站立场,如若转载,请注明出处:https://www.wxx86.cn/program/1269.html