The tab in Python does not automatically start and a still-see format prettytab

Source: Internet
Author: User

Tab
vim/usr/lib64/python2.6/site-packages/tab.py (sys.path View python path, put the custom module in this) import Sysimport Readlineimport Rlcompleterimport atexitimport os readline.parse_and_bind (' tab:complete ') Histfile = Os.path.join (os.environ[' HOME ') , '. Pythonhistory ') try:readline.read_history_file (histfile) except IOError:passatexit.register (readline.write _history_file,histfile) using: Import tab
Prettytable

Download:

Https://code.google.com/p/prettytable/downloads/list

Install: Unzip. CP prettytable.py/usr/lib64/python2.6/site-packages/

chmod+x/usr/lib64/python2.6/site-packages/prettytable.py

Use:

    fromprettytable import   prettytable         >>>print x+------+-----+-----+|  name | age | job |+------+-----+-----+ +------+-----+-----+>>>  x.align[' name '] =  ' l '   (is l , opposite alignment, R: Right-aligned, C: centered) >>> x.add_row ([' Wxl ', ' ' + ', ' IT ']) >>> print x+------+-----+-----+| name | age | job |+------+-- ---+-----+| wxl  |  20 | it | display a specific line: >>> print x.get_ String (start=0,end=1) +------+-----+-----+| name | age | job |+------+-----+----- +| wxl  |  20 | it |+------+-----+-----+   Display specific columns:>>> Print x.get_string (fields=["name"]) 
        +-----------------+                 | name             |        +-----------------+         | wxl              |        | qiandancongjian |         +-----------------+  Sort:  >>>print x.get_string ( Sortby= ' age ')         +-----------------+------------------+-----+         | name             |       age         | job |        +-----------------+------------------+-----+         | wxl              |        20        |  IT |        | qiandancongjian |  2000000000000000 |  it |        +----------------- +------------------+-----+ Reverse: >>>print x.get_string (sortby= ' age ', reversesort=true)          +-----------------+------------------+-----+         | name            |        age        | job |         +-----------------+------------------+-----+        |  Qiandancon

|        WXL | 20 |                 IT | +-----------------+------------------+-----+


The tab in Python does not automatically start and a still-see format prettytab

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.