1 #!/usr/bin/env python2 #_*_ coding:utf-8 _*_3 #three ways to output header information for a code4 5STR1 ='version'6num = 1.07Time ='2016-9-25'8Auther ='Lys'9QQ ='1234567'TenAddr ='Beijing Tian Tong Yuan 301' One A #%10s is preceded by a character, not enough 10 to fill formatted output with the following + Ganso way - #print ('%10s%5s '% (str1,num)). Center (+, ' + ')) - Print(('%10s%10s'% (str1,num)). Center (30,'_')) the Print(('time:%s'% (time)). Center (30)) - Print(('auther:%s'% (auther)). Center (30)) - Print(('qq:% (num) s'%{'Num': QQ}). Center (30)) - #format the output with a dictionary naming method + Print(('my address:% (addr) s'%{'Addr': addr}). Center (60,'+')) - #format output multi-line information + Print(" " A ++++++ version 1.0 +++++++ at time:2016-9-25 - Auther:lys - qq:858504363 - ++++++ My address: Beijing Tian Tong Yuan 301 ++++ - " " - ) in - toinfo =" " + ++++++ version 1.0 +++++++ - time:2016-9-25 the Auther:lys * qq:858504363 $ ++++++ My address: Beijing Tian Tong Yuan 301 ++++Panax Notoginseng " " - Print(info)
Methods for formatting output text