pyhton 实例6 格式化输出


#!/usr/bin/env python
#coding:utf8

''''format output'''


begend = "+"+'*'*48+'+'
mylist = []

while True:
    data = raw_input('input data(. > quit): ')
    if data == '.':
        break
    else:
        mylist.append(data)
        


print begend
for item in mylist:
    print '+'+item.center(48)+'+'
print begend




[root@red-hat-enterprise-linux testpy]# python  formatout.py 
input data(. > quit): 1
input data(. > quit): good
input data(. > quit): 2
input data(. > quit): good
input data(. > quit): .
+************************************************+
+                       1                        +
+                      good                      +
+                       2                        +
+                      good                      +
+************************************************+

你可能感兴趣的:(python)