本文整理汇总了Python中terminaltables.AsciiTable.justify_columns[1]方法的典型用法代码示例。如果您正苦于以下问题:Python AsciiTable.justify_columns[1]方法的具体用法?Python AsciiTable.justify_columns[1]怎么用?Python AsciiTable.justify_columns[1]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类terminaltables.AsciiTable
的用法示例。
在下文中一共展示了AsciiTable.justify_columns[1]方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_pokemon
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns[1] [as 别名]
def print_pokemon(self):
"""Print Pokemon and their stats"""
sorted_mons = sorted(self.pokemon, key=lambda k: (k['num'], -k['iv_percent']))
groups = groupby(sorted_mons, key=lambda k: k['num'])
table_data = [
['Pokemon', 'CP', 'IV %', 'ATK', 'DEF', 'STA']
]
for key, group in groups:
group = list(group)
pokemon_name = self.pokemon_list[str(key)].replace(u'\N{MALE SIGN}', '(M)').replace(u'\N{FEMALE SIGN}', '(F)')
best_iv_pokemon = max(group, key=lambda k: k['iv_percent'])
best_iv_pokemon['best_iv'] = True
for pokemon in group:
row_data = [
pokemon_name,
pokemon['cp'],
"{0:.0f}%".format(pokemon['iv_percent']),
pokemon['attack'],
pokemon['defense'],
pokemon['stamina']
]
table_data.append(row_data)
table = AsciiTable(table_data)
table.justify_columns[0] = 'left'
table.justify_columns[1] = 'right'
table.justify_columns[2] = 'right'
table.justify_columns[3] = 'right'
table.justify_columns[4] = 'right'
table.justify_columns[5] = 'right'
print(table.table)
示例2: test_single_line
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns[1] [as 别名]
def test_single_line():
"""Test single-lined cells."""
table_data = [
['Name', 'Color', 'Type'],
['Avocado', 'green', 'nut'],
['Tomato', 'red', 'fruit'],
['Lettuce', 'green', 'vegetable'],
['Watermelon', 'green'],
[],
]
table = AsciiTable(table_data, 'Example')
table.inner_footing_row_border = True
table.justify_columns[0] = 'left'
table.justify_columns[1] = 'center'
table.justify_columns[2] = 'right'
actual = table.table
expected = (
'+Example-----+-------+-----------+\n'
'| Name | Color | Type |\n'
'+------------+-------+-----------+\n'
'| Avocado | green | nut |\n'
'| Tomato | red | fruit |\n'
'| Lettuce | green | vegetable |\n'
'| Watermelon | green | |\n'
'+------------+-------+-----------+\n'
'| | | |\n'
'+------------+-------+-----------+'
)
assert actual == expected
示例3: print_table
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns[1] [as 别名]
def print_table(table_data):
table = AsciiTable(table_data)
table.inner_row_border = True
if table_data[:1] in ([['TITLE', 'IMDB RATING']],
[['TITLE', 'TOMATO RATING']]):
table.justify_columns[1] = 'center'
print("\n")
print(table.table)
示例4: __report_percentiles
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns[1] [as 别名]
def __report_percentiles(self, summary_kpi_set):
"""
reports percentiles
"""
fmt = "Average times: total %.3f, latency %.3f, connect %.3f"
self.log.info(fmt, summary_kpi_set[KPISet.AVG_RESP_TIME], summary_kpi_set[KPISet.AVG_LATENCY],
summary_kpi_set[KPISet.AVG_CONN_TIME])
data = [("Percentile, %", "Resp. Time, s")]
for key in sorted(summary_kpi_set[KPISet.PERCENTILES].keys(), key=float):
data.append((float(key), summary_kpi_set[KPISet.PERCENTILES][key]))
# self.log.info("Percentile %.1f%%: %.3f", )
table = SingleTable(data) if sys.stdout.isatty() else AsciiTable(data)
table.justify_columns[0] = 'right'
table.justify_columns[1] = 'right'
self.log.info("Percentiles:\n%s", table.table)
示例5: calc_min_delay
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns[1] [as 别名]
damage, hit, base_delay = parts[2:5]
# find weapon sizes
if re.match('.*SIZE_.*SIZE_', line):
# skip long gone items
if 'old ' in title[0:4]:
continue
parts = [x.strip() for x in line.split(',')]
double_hand, single_hand = parts[1:3]
min_delay = calc_min_delay(base_delay)
skill_required = calc_skill_required(base_delay, min_delay)
th = parse_2h_size(double_hand, parse_1h_size(single_hand), parts[0])
table_data.append([title, damage, hit, base_delay, min_delay, skill_required, th])
# table_data = sorted(table_data, key=lambda x: x[0])
table_data.insert(0, header)
table_data.append(header)
table = AsciiTable(table_data)
table.title = table_title
table.inner_footing_row_border = True
table.justify_columns[1] = 'right'
table.justify_columns[2] = 'right'
table.justify_columns[3] = 'right'
table.justify_columns[4] = 'right'
table.justify_columns[5] = 'right'
print(table.table)
print('\r')
print('Last generated on {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
示例6: AsciiTable
# 需要导入模块: from terminaltables import AsciiTable [as 别名]
# 或者: from terminaltables.AsciiTable import justify_columns[1] [as 别名]
Just prints sample text and exits.
"""
from __future__ import print_function
from terminaltables import AsciiTable, DoubleTable
table_data = [
['Platform', 'Years', 'Notes'],
['Mk5', '2007-2009', '\033[37;41mUnavailable\033[0m'],
['MKVI', '2009-2013', 'Might actually be Mk5.'],
]
table = AsciiTable(table_data, 'wangbin')
print()
print(table.table)
table = DoubleTable(table_data, 'Jetta SportWagen')
table.inner_row_border = True
table.justify_columns[2] = 'right'
print()
print(table.table)
table.outer_border = False
table.justify_columns[1] = 'center'
print()
print(table.table)
print()