Python 中的Tab自動不起 和 一個還看的格式prettytab

來源:互聯網
上載者:User

標籤:prettytab

Tab
vim/usr/lib64/python2.6/site-packages/tab.py (sys.path查看Python路徑,把自訂模組放此)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) 使用:import tab
prettytable

下載:

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

安裝:解壓。cp prettytable.py /usr/lib64/python2.6/site-packages/

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

 

使用:

     

    fromprettytable import  PrettyTable         >>>print x+------+-----+-----+| name | age | job |+------+-----+-----++------+-----+-----+>>> x.align[‘name‘] = ‘l‘ (是L ,相靠左對齊,r:靠右對齊,c:置中)>>> x.add_row([‘wxl‘,‘20‘,‘IT‘])>>> print x+------+-----+-----+| name | age | job |+------+-----+-----+| wxl  |  20 | IT |顯示特定行:>>> print x.get_string(start=0,end=1)+------+-----+-----+| name | age | job |+------+-----+-----+| wxl  |  20 | IT |+------+-----+-----+  顯示特定列:>>>print x.get_string(fields=["name"])
        +-----------------+                | name            |        +-----------------+        | wxl             |        | qiandancongjian |        +-----------------+ 排序: >>>print x.get_string(sortby=‘age‘)        +-----------------+------------------+-----+        | name            |       age        | job |        +-----------------+------------------+-----+        | wxl             |        20        | IT |        | qiandancongjian | 2000000000000000 |  IT |        +-----------------+------------------+-----+反排:>>>print x.get_string(sortby=‘age‘,reversesort=True)        +-----------------+------------------+-----+        | name            |       age        | job |        +-----------------+------------------+-----+        | qiandancon

 

         | wxl             |        20        | IT |                 +-----------------+------------------+-----+

 

        

 

 

 


Python 中的Tab自動不起 和 一個還看的格式prettytab

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.