I. INTRODUCTION
Python 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. Installation
Way One: Pip installation
>>> pip Install prettytable
Mode two: Source code installation
wget HTTPS://PYPI.PYTHON.ORG/PACKAGES/SOURCE/P/PRETTYTABLE/PRETTYTABLE-0.7.2.TAR.GZTAR-ZXVF Prettytable-0.7.2.tar.gzpython setup.py buildpython setup.py Install
Three. Use
>>> from prettytable import prettytable>>> x = prettytable ([' Name ', ' age ', ' sex ', ' money ']) >> > x.align["city name"] = "L" >>> x.padding_width = 1>>> X.add_row (["Wang", "a", "man", +]) >>& Gt X.add_row (["Alex", "X", "Man", "+]") >>> x.add_row (["Peiqi", "a", "man", "+]") >>> print (×) +-------+-- ---+-----+-------+| name | Age | sex | Money |+-------+-----+-----+-------+| Wang | 20 | Mans | | | Alex | 21 | Mans | 2000 | | Peiqi | 22 | Mans | |+-------+-----+-----+-------+
Python's prettytable module