Python/Django 生成二维码

1.1 用Python来生成二维码很简单,可以看 qrcode 这个包:

pip install qrcode

qrcode 依赖 Image 这个包:

pip install Image

1.2 安装后就可以使用了,这个程序带了一个 qr 命令:

qr 'http://www.ziqiangxuetang.com' > test.png

1.3 下面我们看一下如何在 代码 中使用

import qrcode
 
img = qrcode.make('http://www.tuweizhong.com')
# img <qrcode.image.pil.PilImage object at 0x1044ed9d0>
 
with open('test.png', 'wb') as f:
    img.save(f)

安装:

pip install git+git://github.com/ojii/pymaging.git#egg=pymaging
pip install git+git://github.com/ojii/pymaging-png.git#egg=pymaging-png

使用方法大致相同,命令行上:

qr --factory=pymaging "Some text" > test.png

Python中调用:

import qrcode
from qrcode.image.pure import PymagingImage
img = qrcode.make('Some data here', image_factory=PymagingImage)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值