Skip to content

Latest commit

 

History

History
51 lines (41 loc) · 1.99 KB

可视化.表格.md

File metadata and controls

51 lines (41 loc) · 1.99 KB

一、引入库

pip install prettytable
from prettytable import PrettyTable

二、编程

table = PrettyTable(['编号', '云编号', '名称', 'IP地址'])
table.add_row(['1', 'server01', '服务器01', '172.16.0.1'])
table.add_row(['2', 'server02', '服务器02', '172.16.0.2'])
table.add_row(['3', 'server03', '服务器03', '172.16.0.3'])
table.add_row(['4', 'server04', '服务器04', '172.16.0.4'])
table.add_row(['5', 'server05', '服务器05', '172.16.0.5'])
table.add_row(['6', 'server06', '服务器06', '172.16.0.6'])
table.add_row(['7', 'server07', '服务器07', '172.16.0.7'])
table.add_row(['8', 'server08', '服务器08', '172.16.0.8'])
table.add_row(['9', 'server09', '服务器09', '172.16.0.9'])
table.add_rows([['10', 'server10', '服务器10', '172.16.0.9'],
               ['11', 'server11', '服务器11', '172.16.0.9']])
# table.add_row(['9', 'server09', '服务器09', '172.16.0.9'])
# table.add_row(['9', 'server09', '服务器09', '172.16.0.9'])
print(table)
+------+----------+----------+------------+
| 编号 |  云编号  |   名称   |   IP地址   |
+------+----------+----------+------------+
|  1   | server01 | 服务器01 | 172.16.0.1 |
|  2   | server02 | 服务器02 | 172.16.0.2 |
|  3   | server03 | 服务器03 | 172.16.0.3 |
|  4   | server04 | 服务器04 | 172.16.0.4 |
|  5   | server05 | 服务器05 | 172.16.0.5 |
|  6   | server06 | 服务器06 | 172.16.0.6 |
|  7   | server07 | 服务器07 | 172.16.0.7 |
|  8   | server08 | 服务器08 | 172.16.0.8 |
|  9   | server09 | 服务器09 | 172.16.0.9 |
|  10  | server10 | 服务器10 | 172.16.0.9 |
|  11  | server11 | 服务器11 | 172.16.0.9 |
+------+----------+----------+------------+