def printPicnic(dic,left,right): print("PICNIC ITEMS".center(left+right,"-")) for i in dic: print(i.ljust(left,"*")+str(dic[i]).rjust(right," ")) dic={‘apple‘:5, ‘nanana‘:22, ‘pear‘:13, ‘peach‘:6} printPicnic(dic,10,6) printPicnic(dic,6,10)
Posted lnliyang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了左右对其相关的知识,希望对你有一定的参考价值。
def printPicnic(dic,left,right): print("PICNIC ITEMS".center(left+right,"-")) for i in dic: print(i.ljust(left,"*")+str(dic[i]).rjust(right," ")) dic={‘apple‘:5, ‘nanana‘:22, ‘pear‘:13, ‘peach‘:6} printPicnic(dic,10,6) printPicnic(dic,6,10)
以上是关于左右对其的主要内容,如果未能解决你的问题,请参考以下文章