V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
xiahei
V2EX  ›  Python

Python 终端打印二维码

  •  
  •   xiahei · 2016-08-18 12:02:30 +08:00 · 6559 次点击
    这是一个创建于 2815 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这些天颓废不想学习,故又倒腾这小小玩具,其中一个是 QQ 机器人(QQRobot),模拟登录的时候需要扫二维码,一番搜索之后发现了 pyqrcode 这个库,但是用了发现不是很如意。有些时候打印出来的二维码都是无效的。所以自己写了一个函数(在这里),效果大概是这样,大小 66x33 ,一屏才 40+行,所以几乎占满了一屏。而且发现这显示效果跟终端使用的字体,行距,字体大小之类都有关系,所以想知道有没有更优雅的解决方案?能兼容不同字体大小行距之类…… THX !

    9 条回复    2019-01-10 02:05:44 +08:00
    willwill
        1
    willwill  
       2016-08-18 12:38:10 +08:00 via iPhone
    qrencode
    vinan143
        2
    vinan143  
       2016-08-18 12:54:01 +08:00
    https://github.com/lincolnloop/python-qrcode 看过这个源码,要对 QRcode 的生成过程算法非常熟悉。。
    xiahei
        3
    xiahei  
    OP
       2016-08-18 13:32:00 +08:00
    @vinan143 这个库很强啊……但是他是生成,我想要打印………… THX !
    notolddriver
        4
    notolddriver  
       2016-08-18 13:36:23 +08:00
    xiahei
        5
    xiahei  
    OP
       2016-08-18 13:47:28 +08:00
    @willwill @notolddriver @vinan143
    orz ,感谢! qrencode 在 Linux 下完美! THX !
    coolloves
        6
    coolloves  
       2016-08-18 20:21:11 +08:00 via Android
    马克!!!
    chao591
        7
    chao591  
       2017-02-10 22:06:04 +08:00
    https://github.com/alishtory/qrcode-terminal
    这个模块,亲测可以在控制台完美打印额
    xiahei
        8
    xiahei  
    OP
       2017-02-11 12:54:05 +08:00 via Android
    @chao591 这个似乎跟我之前的是一样的显示效果?两个字符一个二维码方块儿? qrencode 这应该显示效果完美了,想看看能不能转成 Python 库。 THX !
    beautifulzzzz
        9
    beautifulzzzz  
       2019-01-10 02:05:44 +08:00
    有些安卓手机的二维码识别需要黑底白块,建议选中二维码再用手机识别试试
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2287 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:00 · PVG 11:00 · LAX 20:00 · JFK 23:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.