#【ライブラリ説明】
辞書を見やすいテーブルにする
#【プログラム】
table_printer.py
# -*- coding: utf-8 -*-
from table_printer import TablePrinter
fmt = [
('Title', 'title', 20, 'left'),
('Description', 'description', 20, 'right'),
]
data = [{'title': 'Hello', 'description': 'World'}]
totals = {'title': 'TOTAL', 'description': '1 title'}
print TablePrinter(fmt, sep='|', ul='=', tl='-', bl='_')(data, totals)
#【結果】
table_printer.txt
--------------------|--------------------
Title | Description
====================|====================
Hello | World
====================|====================
TOTAL | 1 title
____________________|____________________