dict = {‘apple‘:4,‘banana‘:10,‘pear‘:8} def printItem(dictName,leftwidth,rightwidth): print("Menu".center(leftwidth+rightwidth,‘-‘)) for i,k in dictName.items(): print(i.ljust(leftwidth,‘.‘) + str(k).rjust(rightwidth)) printItem(dict,20,4)
----------Menu---------- banana.............. 10 pear................ 8 apple............... 4 Process finished with exit code 0
时间: 2024-10-11 03:28:04