简体   繁体   中英

Python Texttable - Total width for each row

Is there a method to determine the column width for the Table after the rows have been added. For example even if I set initialization parameters below:

 text_table = Texttable( max_width= 160)

The table may default to a smaller size if the row's total width is less than the number, which is a good rendering. However, I would like to know what was the actual width for the entire row, in the case of rows where the width does not hit the max_width limit.

The solution text_table.width returns a list of numbers but the sum does not equate the table width.

Using the following accurately returns.

table_width = max( [ len(x) for x in table_as_str.split('\n') ])

where table_as_str is the result from text_table.draw()

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM