# encoding: utf-8 #-*- coding: UTF-8 -*- # 版权所有 2023 ©涂聚文有限公司 # 许可信息查看: # 描述: # Author : geovindu,Geovin Du 涂聚文. # IDE : PyCharm 2023.1 python 311 # Datetime : 2023/7/5 11:08 # User : geovindu # Product : UI # Project : pythonTkinterDemo # File : main.py # explain : 学习 import pyzbar.pyzbar as p import pyqrcode import qrcode def generateQrCode(qrcodestr:str,qrcodefile:str): """ 生成二维码 :param qrcodestr: 二要生成的二给码字符 :param qrcodefile: 生成的文件名 :return: """ img = qrcode.make(qrcodestr) type(img) img.save(f'{qrcodefile}.png') def readQrCode(qrcodefile:str): """ 读二维码 :param qrcodefile: 二维码文件名 :return: 返回二维码内容 """ nowpath = os.getcwd() scrimg=Image.open(f"{nowpath}\{qrcodefile}.png") m=p.decode(scrimg) codedata=m[0].data.decode("utf-8") return codedata
调用:
nowpath = os.getcwd() #当前项目文件夹 generateQrCode("http://www.dusystem.com","geovindu") codedata=readQrCode("geovindu") print("qrcode:",codedata)
标签:python,codedata,decode,qrcode,二维码,QrCode,geovindu,qrcodefile From: https://www.cnblogs.com/geovindu/p/17538037.html