python将url转变成二维码图片
将url数据转变成二维码数据,再将二维码图片转成base64格式返回
import qrcode import io def url_image(self,url): img = qrcode.make(url) img = img.get_image() in_mem_file = io.BytesIO() img.save(in_mem_file, format="PNG") in_mem_file.seek(0) img_bytes = in_mem_file.read() base64_encoded_result_bytes = base64.b64encode(img_bytes) base64_encoded_result_str = base64_encoded_result_bytes.decode('ascii') return base64_encoded_result_str