[英]How to erase middle vertical line in prettytable, Python?
I printed this table.我打印了这张表。 I can do it only for first string with installed PTable.我只能对安装了 PTable 的第一个字符串执行此操作。
def table_example():
"""It is needed to install PTable to have title line"""
table = PrettyTable()
table.title = 'Results for method'
table.field_names = ['EWRWE', 'WERWER']
table.add_row(['qwer', 3.14])
table.add_row(['ewr', 42.0])
print(table)
+--------------------+
| Results for method |
+---------+----------+
| EWRWE | WERWER |
+---------+----------+
| qwer | 3.14 |
| ewr | 42.0 |
+---------+----------+
I need to erase vertical line for second string too.我也需要擦除第二个字符串的垂直线。 How to do so in any python library?如何在任何 python 库中这样做?
There are a few options you can apply to table here.您可以在此处将一些选项应用于表格。 The one you are looking for is vrules.您正在寻找的是 vrules。
I apply like this and the resulting styles are as follows and I believe you're looking for table.vrules=0
我这样申请,得到的 styles 如下,我相信你正在寻找table.vrules=0
from prettytable import PrettyTable
def table_example():
"""It is needed to install PTable to have title line"""
table = PrettyTable()
table.title = 'Results for method'
table.subtitle = 'QWER'
table.field_names = ['EWRWE', 'WERWER']
table.add_row(['qwer', 3.14])
table.add_row(['ewr', 42.0])
table.vrules=0
print(table)
# +--------------------+
# | Results for method |
# +--------------------+
# | EWRWE WERWER |
# +--------------------+
# | qwer 3.14 |
# | ewr 42.0 |
# +--------------------+
table.vrules=1
print(table)
# +--------------------+
# | Results for method |
# +---------+----------+
# | EWRWE | WERWER |
# +---------+----------+
# | qwer | 3.14 |
# | ewr | 42.0 |
# +---------+----------+
table.vrules=2
print(table)
# Results for method
# ----------------------
# EWRWE WERWER
# ----------------------
# qwer 3.14
# ewr 42.0
# ----------------------
table_example()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.