本文整理汇总了Python中table.Table.header[:]方法的典型用法代码示例。如果您正苦于以下问题:Python Table.header[:]方法的具体用法?Python Table.header[:]怎么用?Python Table.header[:]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table.Table
的用法示例。
在下文中一共展示了Table.header[:]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_addr_refs
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import header[:] [as 别名]
def display_addr_refs(refs, ref_statuses):
table = Table(
num_cols=len(REF_COL_NAMES), width=TABLE_WIDTH, alignment='right')
table.header[:] = REF_COL_NAMES
for ref, ref_status in zip(refs, ref_statuses):
if ref.tag is not None:
ref_tag = ref.tag
else:
ref_tag = 'n/a'
if ref.index is not None:
ref_index = ref.index
else:
ref_index = 'n/a'
if ref.offset is not None:
ref_offset = ref.offset
else:
ref_offset = 'n/a'
# Display data for each address as a row in the table
table.rows.append((
ref.word_addr,
prettify_bin_addr(ref.bin_addr, MIN_BITS_PER_GROUP),
prettify_bin_addr(ref_tag, MIN_BITS_PER_GROUP),
prettify_bin_addr(ref_index, MIN_BITS_PER_GROUP),
prettify_bin_addr(ref_offset, MIN_BITS_PER_GROUP),
ref_status))
print(table)
示例2: display_cache
# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import header[:] [as 别名]
def display_cache(cache):
table = Table(
num_cols=len(cache), width=TABLE_WIDTH, alignment='center')
table.title = 'Cache'
cache_set_names = sorted(cache.keys())
# A cache containing only one set is considered a fully associative cache
if len(cache) != 1:
# Display set names in table header if cache is not fully associative
table.header[:] = cache_set_names
# Add to table the cache entries for each block
table.rows.append([])
for index in cache_set_names:
blocks = cache[index]
table.rows[0].append(
' '.join(','.join(map(str, entry['data'])) for entry in blocks))
print(table)