python学习

python代码实现生成二维码图片

2020-11-11  本文已影响0人  小阿六Minasix

1.安装qrcode模块

方法:pip install qrcode

2.代码示例

import qrcode
# 更复杂的设置参考 https://blog.csdn.net/xc_zhou/article/details/80952036
def qr_code_1(canshu):
    #调用qrcode的make()方法传入url或者想要展示的内容
    img = qrcode.make(canshu)
    #保存
    img.save("./text1.png")
    # 或者
    #with open('./test2.png', 'wb') as f:
     #   img.save(f)
if __name__=='__main__':
    qr_code_1("我是要生成二维码的文字")
上一篇 下一篇

猜你喜欢

热点阅读