V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
shq1995
V2EX  ›  Python

分享一个自己写的 python 库,也许大家以后有点小用。

  •  
  •   shq1995 · Aug 10, 2015 · 3251 views
    This topic created in 3913 days ago, the information mentioned may be changed or developed.
    仓库地址: https://github.com/Leviathan1995/Pylsy
    希望大家多点star.
    已经添加包管理了,可以直接下载:
    pip install pylsy

    作用就是可以方便在终端中输出表格,类似mysql数据库。
    attributes=["name","age","sex","id","time"] #添加表格的属性
    table=PylsyTable(attributes) #创建表格
    name=["sun","lsy","luna","leviathan"] #属性的值
    age=[20,21,23,25]
    table.AddData("age",age)
    table.AddData("name",name) #添加属性的值
    table.CreateTable() #打印表格


    欢迎star ,fork , 提意见,pull request.
    10 replies    2015-08-12 12:27:05 +08:00
    shq1995
        1
    shq1995  
    OP
       Aug 10, 2015
    暂时还不支持中文,有什么改进的地方,大家尽管提
    21grams
        2
    21grams  
       Aug 10, 2015 via Android
    用处不大
    shq1995
        3
    shq1995  
    OP
       Aug 10, 2015
    @21grams 有时候你需要终端输出的时候,比较有用,和mysql那个展示一样
    ipconfiger
        4
    ipconfiger  
       Aug 10, 2015
    为什么不支持中文?
    @shq1995
    shq1995
        5
    shq1995  
    OP
       Aug 10, 2015
    @ipconfiger 因为一个中文的长度是3个,目前还没有对中文进行判断,等实习结束了,回学校了,我会添加中文功能的。
    saber000
        6
    saber000  
       Aug 12, 2015
    发了一个pull request来支持中文
    对于列宽的处理,一个供参考的方法是判断字符串的每位是否在string.printable,如果不在则认为是中文,宽度加二
    当然用正则也ok
    shq1995
        7
    shq1995  
    OP
       Aug 12, 2015
    @saber000 我测试了,字符类型错误
    shq1995
        8
    shq1995  
    OP
       Aug 12, 2015
    @saber000 Python 2.7
    shq1995
        9
    shq1995  
    OP
       Aug 12, 2015
    @saber000 并不是中文需要占三个长度位置,而是中文只占一个位置,但它测试出来长度为3
    saber000
        10
    saber000  
       Aug 12, 2015
    @shq1995 中文请用Unicode
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2889 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 15:32 · PVG 23:32 · LAX 08:32 · JFK 11:32
    ♥ Do have faith in what you're doing.