Code Monkey home page Code Monkey logo

printtable's Introduction

Printtable是一个可以在terminal上输出数据表样式的python公共库。

image

下载方式

pip install printtable

使用示例

引用printtable
from printtable import PrintTable
首先我们需要构建表的表头,然后创建表
attributes=[['name','old']] table = PrintTable(attributes)
然后我们有两种方式向表内加入数据
  1. append_data:可以通过明确特征来加入一行数据中的一部分数据或者多行数据。

    table.append_data(name="Jack",old = "20")
    table.append_data(name =["Jack","Mary"], old =["20","19"])
    
  2. append_data_list: 可以直接使用list格式的变量向表中加入一行数据。不过要注意数据的顺序要符合创建表时的表头相同。

    table.append_data_list(["Jack","20"]) 
    
支持加入中文数据,但表头目前只能支持英文。
table.append_data(name = "小明",old = "20")
table.append_data(name =["小华","大傻"], old =["20","19"])
table.append_data_list(["二傻子","20"]) 
最后我们可以在terminal直接输出ASCII表。通过line_num参数来控制在每行数据前是否加上行号,1为加入,默认为不加入行号。
table.printTable(1) table.printTable()

printtable's People

Contributors

prozhuchen avatar

Watchers

James Cloos avatar  avatar

Forkers

python3pkg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.