PrettyTable

Installation

pip install PTable 


#=============== Import PrettyTable ================#
from prettytable import PrettyTable

#============== Create Object ======================#
mytable = PrettyTable()

#============== Field Name    =======================#
mytable.field_names = ['Sl','Name','Roll','Class']

#=============     Add Row    =======================#
mytable.add_row([1,'Olee Ahmmed',1,10])
mytable.add_row([2,'Mahmuda Farhana Mim',2,10])

#================ Print Table ========================#
print(mytable)

#================ Delete A Row =======================#
mytable.del_row(0)

#================ Clear Table Data ===================#
mytable.clear_rows()

Output Table 👍


+----+---------------------+------+-------+
| Sl |         Name        | Roll | Class |
+----+---------------------+------+-------+
| 1  |     Olee Ahmmed     |  1   |   10  |
| 2  | Mahmuda Farhana Mim |  2   |   10  |
+----+---------------------+------+-------+


After Delete A Row Output👍
+----+---------------------+------+-------+
| Sl |         Name        | Roll | Class |
+----+---------------------+------+-------+
| 2  | Mahmuda Farhana Mim |  2   |   10  |
+----+---------------------+------+-------+

Last updated