打印好看的整齐的清单

def catalogPrint(content,lwidth,rwidth):
print('picnicItems'.center(lwidth+rwidth,'='))
for j,k in content.items():
print(j.ljust(lwidth,'.')+str(k).rjust(rwidth))
picnicItems = {'sandwiches': 4, 'apples': 12, 'cups': 4, 'cookies': 8000}
catalogPrint(picnicItems,30,4)

'''

picnicItems 野餐用品清单
===========picnicItems============
sandwiches.................... 4
apples........................ 12
cups.......................... 4
cookies.......................8000

posted @ 2019-03-13 16:13  晨光曦微  阅读(223)  评论(0编辑  收藏  举报