zoukankan      html  css  js  c++  java
  • 打印标准目录

    》题目要求

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

    》题目目的

      熟练掌握字符串  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

    》改进方案

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

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

  • 相关阅读:
    Bubble Sort (5775)
    Dertouzos (5750)
    codeforces 360 E
    codeforces 360 D
    codeforces 360 C
    Mike and Cellphone
    训练2——B
    训练1——A
    符号三角形
    Sudoku Killer
  • 原文地址:https://www.cnblogs.com/NeverCtrl-C/p/6129531.html
Copyright © 2011-2022 走看看