NeverCtrl-C

》题目要求

  将用户提供的字典数据,想目录一样打印出来

》题目目的

  熟练掌握字符串  rjust()  ljust()  center()  的使用方法

》程序实现 

 1 import pprint
 2 imf = {"warrior": 2453,
 3        "fury": 28,
 4        "bob": 1254658}
 5 pprint.pprint(imf)
 6 
 7 def test(itemsDict, rightWidth, leftWidth):
 8     print("The information of name and age".center(rightWidth + leftWidth, "="))
 9     for k, v in itemsDict.items():
10         print(k.ljust(leftWidth,".") + str(v).rjust(rightWidth,"."))
11 
12 test(imf,10,20)
View Code

》改进方案

  用户输入标题和对应的页码,当用户输入完毕后将其按照标准的目录格式打印出来

  今天下午食堂(二饭二楼清真食堂)的鱼太难吃啦,导致三少不想更新,待更新中.......

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-10-18
  • 2021-08-19
  • 2022-02-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-07-30
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案