Gitlib Gitlib
首页
  • 分类
  • 标签
  • 归档
  • Golang开发实践万字总结
  • MySQL核心知识汇总
  • Redis实践总结
  • MQ实践万字总结
  • Docker数据持久化总结
  • Docker网络模式深度解读
  • 常用游戏反外挂技术总结
  • 读书笔记
  • 心情杂货
  • 行业杂谈
  • 友情链接
关于我
GitHub (opens new window)

Ravior

以梦为马,莫负韶华
首页
  • 分类
  • 标签
  • 归档
  • Golang开发实践万字总结
  • MySQL核心知识汇总
  • Redis实践总结
  • MQ实践万字总结
  • Docker数据持久化总结
  • Docker网络模式深度解读
  • 常用游戏反外挂技术总结
  • 读书笔记
  • 心情杂货
  • 行业杂谈
  • 友情链接
关于我
GitHub (opens new window)
  • PHP

  • Golang

  • Python

    • Python使用lambda表达式
    • Python之线程池
    • Python之装饰器
    • Python之chardet模块使用
    • Python之copy模块使用
    • Python之functools模块使用
    • Python之hashlib模块使用
    • Python之json模块使用
    • Python之pickle模块使用
    • Python之pid模块使用
    • Python之pypinyin模块使用
    • Python之pyqrcode模块使用
      • 安装
      • 主要方法
      • 代码测试
    • Python之threading模块使用
    • Python之base64模块使用
    • Python项目Docker打包
  • Javascript

  • 其他语言

  • 编程语言
  • Python
Ravior
2014-05-02
目录

Python之pyqrcode模块使用

pyqrcode是用来生成二维码的第三方模块,可以在控制台输出二维码,也可以将二维码保存为图片,不过依赖pypng包。

# 安装

pip install pypng
pip install pyqrcode
1
2

# 主要方法

  • create(url): 创建二维码
  • png(path): 将二维码保存为png
  • svg(path): 将二维码保存为svg
  • terminal(): 获取二维码输出到终端的信息

# 代码测试

# encoding=utf-8
# 作用: 二维码生成
# pip install pypng
# pip install pyqrcode

import logging
import os
logging.basicConfig(level = logging.DEBUG, format='%(levelname)s - %(message)s')

logger = logging.getLogger(__name__)

import pyqrcode

qr = pyqrcode.create("https://gitlib.com")

if not os.path.exists('qrcode'):
	os.mkdir('qrcode')

# 生成二维码图片
qr.png(os.path.join('qrcode', 'qrcode.png'), scale=8)
qr.svg(os.path.join('qrcode', 'qrcode.svg'), scale=8)
qr.eps(os.path.join('qrcode', 'qrcode.eps'), scale=2)
# 打开png图片
# qr.show()
# 在终端打印二维码
print(qr.terminal(quiet_zone=1))


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Python
上次更新: 2022/12/01, 11:09:34
Python之pypinyin模块使用
Python之threading模块使用

← Python之pypinyin模块使用 Python之threading模块使用→

最近更新
01
常用游戏反外挂技术总结
11-27
02
Golang开发实践万字总结
11-11
03
Redis万字总结
10-30
更多文章>
Theme by Vdoing | Copyright © 2011-2022 Ravior | 粤ICP备17060229号-3 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式