1. 功能
使用 qrcode 生成二维码
2. 代码
- # 生成二维码:
- import qrcode
- # 根据 url 生成二维码
- def qrcodeWithUrl(url):
- img = qrcode.make(url)
- savePath = "1.png"
- img.save(savePath)
- # 根据输入的文字生成二维码
- def qrcodeWithText(text):
- img = qrcode.make(text)
- savePath = "2.png"
- img.save(savePath)
- # 输入一句话
- content = input("请输入一名话:")
- if "http" in content:
- qrcodeWithUrl(content)
- else:
- qrcodeWithText(content)
- print("二维码已生成完毕, 请查看!")
来源: http://www.bubuko.com/infodetail-2674730.html