格式化输出

格式化输出

% s d:%就是占位符,s和d是替换的内容的类型:s是字符串类型,d是数字类型,digit

name = input('输入名字:')
age = input('输入年龄')
hg = input('输入身高')
msg = ('我叫%s,年龄是%s,身高是%s,' %(name,age,hg))
print(msg)

# 当格式化输出内容中遇到存在百分号时,再前面再加一个%

name = input('输入名字:')
age = int(input('输入年龄:'))
hg = input('输入身高:')
msg = ('我叫%s,年龄是%d,身高是%s,学习进度为3%%' %(name,age,hg))
print(msg)

 

posted @ 2021-03-25 19:40  吃啥呦?  阅读(37)  评论(0)    收藏  举报