python基础之格式化输出

格式化输出

格式化输出指为了美观和简化书写,将特定字符简化输出
%s,一般指字符串
%d,一般指数字
%%,一般描述对象中如果有%,为了防止混用,使用%%让系统确认这个是百分号 (template = "%s现在手机的电量是100**%%**" %(name,)
template = "我是%s,年龄%s, 职业%s。" %("alex",73,'讲鸡汤',) # 格式:'对象'%(a,b,c,)

 

posted @ 2019-11-04 15:57  小蚂农  阅读(107)  评论(0编辑  收藏  举报