【发布时间】:2019-03-05 17:01:01
【问题描述】:
我使用python包qrcode从url生成二维码图片:
url='www.google.com'
qr = qrcode.QRCode(version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4)
qr.add_data(url)
qr.make(fit=True)
img = qr.make_image()
return img
如何将img保存到磁盘的某个路径?
我试过了:
image_file = open(path_qr_code, 'w')
image_file.write(img)
image_file.close
但我明白了:
TypeError: write() 参数必须是 str,而不是 PilImage
【问题讨论】:
-
提示:“不是 PIL 图像”,然后您可以搜索“如何将 PIL 图像保存到磁盘”。
标签: python-3.x save qr-code