1

Day 1. 占位符的使用方法(%d,%s)(格式化输出)

方法1 

name = input("请输入名字1")

age = input ("请输入年龄")

hobby = input("请输入兴趣爱好")

msg = ("我的名字叫做%s,今年 %d,我的兴趣爱好是%s") %(name,age,hobby)

print(msg)

 

方法2

name1 = input("请输入你的名字")

age1 = input("请输入你的年龄")

score1 = input("请输入你的成绩")

msg="我的名字叫做%(name)s,今年%(age)d 岁,我的考试成绩是%(score)s" %{ ‘name’:name1,'age':age1,'score:score1'}

print(msg)

posted @ 2018-01-22 15:15  萌哥-爱学习  阅读(1151)  评论(0编辑  收藏  举报