Python Utility library: prettytable Learning
Prettytable description
Prettytable is a third-party library in Python that can be used to generate beautiful, ASCII-formatted tables that are useful.The following is an official introduction:
A Simple Python Library for easily displaying tabular data in a visually appealing ASCII table format.Prettytable is a si
I. INTRODUCTIONPython outputs the output as a tabular format through the prettytable module, and Python itself is not built-in and requires a separate installation of the third-party library.Two. InstallationWay One: Pip installation>>> pip Install prettytableMode two: Source code installationwget HTTPS://PYPI.PYTHON.ORG/PACKAGES/SOURCE/P/PRETTYTABLE/PRETTYTABLE-
Python prettytable ModulePython outputs the output as a tabular format via the Prettytable module1. Installing prettytablePip Install prettytable 2. ExampleFrom prettytable Import Prettytablex = prettytable ([' City name ', ' area ', ' Population ', ' annual rainfall ']) x.
Python PrettyTable module, pythonprettytableI. Introduction
Python uses the prettytable module to output the output content in a table. python itself is not built-in and requires independent installation of this third-party library.Ii. Installation
Method 1: pip Installation
>>> pip install PrettyTable
Method 2: source code Installation
wget https://pypi.python.
Brief introductionPython outputs the output as a tabular format through the prettytable module, and Python itself is not built-in and requires a separate installation of the third-party library.Installation1 pip install prettytable1 # Source Installation 2 wget https://pypi.python.org/packages/source/P/PrettyTable/prettytable-0.7.2. tar.gz3 tar-zxvf
>>> from prettytable import prettytable>>> x = prettytable ([' City name ', ' area ', ' Population ', ' annual R Ainfall "]) >>> x The prettytable of Python
Recently I saw the use of Python to realize the train ticket query, I also realized, feel a lot of harvest, below I will each step of the detailed to share out. (Note that the Python3 is used)
First I show the final result:
Execute at cmd command line: Python tickets.py-dk Shanghai Chengdu 20161007 > Result.txt
Check the train information of Shanghai-Chengdu 2016.10.07 D and K, and save it to Result.txt file; The following is the result of the Result.txt file:
The following will be the i
Recently I saw the use of Python to realize train ticket query, I also realized, I feel a lot of harvest, the following I will each step in detail to share. (Note that the Python3 is used)
First I show the final result:
Execute at cmd command line: Python tickets.py-dk Shanghai Chengdu 20161007 > Result.txt
Check the train information of Shanghai-Chengdu 2016.10.07 D and K, and save to Result.txt file; Here is the result in the Result.txt file:
The following will be the implementation steps:
Faster than 12306! Use Python to write a train ticket viewer ~, Python 12306
Author: Wayne Shi
Link: https://zhuanlan.zhihu.com/p/22235740
When you are going out to play and want to query the train ticket information, are you still using the 12306 official website? Next we will use Python to write a line-of-command line train ticket viewer. You only need to type a line-of-command on the command line to get the train ticket information you want!
1. Experiment Introduction
1.1 knowledge points
Eleven Python libraries you may not know
There are so many Python packages that almost no one can master. Only PyPI can list 47,000 packages separately!
Recently, when I heard a lot of data scientists switch to Python, I couldn't help but think that although they have some huge benefits of pandas, scikit-learn, and numpy, however, I missed some Python libraries that were a little older but also helpful.
In this article, I will introduce some little-known libraries. Even if you are already a Pyt
More and more data scientists have been using Python recently, and I can't help but think that although they have benefited from the libraries of Pandas, Scikit-learn and NumPy, they may have missed some of the older but equally helpful python libraries.
In this blog post, I will recommend some little-known libraries. Even if you're a Python whiz, you should take a look at one or two libraries that you've never seen before.1) Delores
Dolorean is a cool date/time library. In addition to the nic
Recently, as more and more data scientists began to use Python, I could not help but think that although they benefited from the libraries of Pandas, Scikit-learn and NumPy, they might have missed some of the older but also helpful python libraries.
In this blog post, I will recommend to you some little-known libraries. Even if you're a Python master, you should look at one or two of these libraries that you've never seen before.1) Delores
Dolorean is a cool date/time library. In addition to th
/Eastern"d = Delorean(timezone=EST)
2) prettytable
This package is stored on GoogleCode, so you may have never heard of it. Google Code is now as desolate as Siberia.
Although it has been moved to an ice-and-snow, deserted place, prettytable is still the best structured output library, which can build good output in terminals or browsers. Therefore, if you are using a new IPython Notebook plug-in, we recom
programs is to use the Virtualenv tool to build a virtual environment. Our program uses PYTHON3 development, below in your working directory to build a folder tickets, go in to create a virtual environment and activate it:$ virtualenv-p/usr/bin/python3 venv$. Venv/bin/activateInstall the library you need to use for your experiment:$ sodo pip Install requests prettytable docopt
Requests, no more introduction, use Python to access the HTTP res
1) DeLorean
Very cool date/Time library
Copy the Code code as follows:
From DeLorean import DeLorean
EST = "Us/eastern"
D = DeLorean (Timezone=est)
2) prettytable
Good output can be built in a browser or terminal
Copy the Code code as follows:
From prettytable import prettytable
Table = prettytable (["Animal", "fer
futurefrom delorean import DeloreanEST = "US/Eastern"d = Delorean(timezone=EST)2) prettytableThere ' s a chance you haven ' t heard prettytable of because it's listed on Googlecode, which is basically the coding equivalent of Siberia.Despite being exiled to a cold, snowy and desolate place, was prettytable great for constructing output that looks good in the Te Rminal or in the browser. So if you ' re work
Label:1, ready to install the Python MySQL module "mysqldb" and the Python form module "prettytable" (previous article has been introduced, not repeat here) [[email protected] ~]# python
python 2.6.6 (r266:84292, Jan, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7 -4)] on linux2
Type ' help ', ' copyright ', ' credits ' or ' license ' for more information.
>>> Import mysqldb
>>> from prettytable import
1) DeLorean
Very cool date/Time library
Copy Code code as follows:
From DeLorean import DeLorean
EST = "Us/eastern"
D = DeLorean (Timezone=est)
2) prettytable
Good output can be built in a browser or terminal
Copy Code code as follows:
From prettytable import prettytable
Table = p
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.