Python学习(四)格式化输出

# 格式化输出
# % s  d

# name = input("please input your name : ")
# age = input("please input your age : ")
# job = input("please input your job : ")
# # msg = '我叫%s , 今年%s' %(name,age)
# # print(msg)
#
#
#
# # %%  两个%%是为了转义  %  否则直接写57% 会报格式错误
#
# msg1 = '''-----------------info of %s
# name : %s
# age : %s
# job : %s
# score : 56%%  
# --------------------------end of poem
#
# '''% (name,name,age,job)
# print(msg1)

# 另外一种格式化输出  format

s2 = "my name is {},this year is {},my hobby is {},i love {}".format('smith','2019','coding','coding')
print(s2)

s3 = "my name is {0},this year is {1},my hobby is {2},i love {1}".format('smith','2019','coding','coding')
print(s3)


s4 = "my name is {aaa},this year is {name},my hobby is {age},i love {age1}".format(name='smith',age='2019',age1='coding',aaa='coding')
print(s4)








转载于:https://www.cnblogs.com/rookieagle/p/10269860.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值