0

I printed this table. I can do it only for first string with installed 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?

1 Answers1

0

There are a few options you can apply to table here. The one you are looking for is vrules.

I apply like this and the resulting styles are as follows and I believe you're looking for 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()
Johnny John Boy
  • 3,009
  • 5
  • 26
  • 50