我想以表格格式打印Python字典,但是在处理字典时遇到了困难。以下是我的字典:
board_dict =
{
'Done': {
'point': 0.0,
'items': 1
},
'Doing': {
'point': 24.0,
'items': 3
},
'New': {
'point': 0.0,
'items': 2
},
'Stuck': {
'point': 19.0,
'items': 3
},
'Ready to Test': {
'point': Decimal('1'),
'items': 1
}
}
我正在尝试设计类似于这样的东西:
Column Items Points
------ ----- ------
Sprint Backlog 0 0
Doing 3 24
Stuck 3 19
Code Review 0 0
Ready to Test 1 1
Done 1 0
------
Total 8 44
------
我已经尝试使用Python的tabulate
库:https://pypi.org/project/tabulate/
print(tabulate(board_dict, headers="keys", tablefmt="fancy_grid"))
╒════════╤═════════╤═══════╤═════════╤═════════════════╕
│ Done │ Doing │ New │ Stuck │ Ready to Test │
╞════════╪═════════╪═══════╪═════════╪═════════════════╡
│ point │ point │ point │ point │ point │
├────────┼─────────┼───────┼─────────┼─────────────────┤
│ items │ items │ items │ items │ items │
╘════════╧═════════╧═══════╧═════════╧═════════════════╛
非常感谢您的帮助。
pandas
并检查过了,一切都很完美!谢谢。 - DonOfDen