%(格式化字符串)几种格式的使用

%(格式化字符串)

name = input('请输入姓名:')
age =input('请输入年龄: ')
height =input('请输入身高: ')
msg ="我叫%s 今年%s  身高%s" % (name,age,height)
print(msg)
Name = input('请输入姓名:')
Age =input('请输入年龄: ')
job =input('请输入工作: ')
Hobbie=input('你的爱好: ')
msg = '''——————info of %s——————
Name  :%s
Age   :%d
job   :%s
Hobbie:%s
————————end——————————'''% (Name,Name,int(Age),job,Hobbie)
print(msg)
name = input('请输入姓名:')
age =int(input('请输入年龄: '))
height =input('请输入身高: ')
msg ="我叫%s 今年%s  身高%s,学习进度3%%s" % (name,age,height) #想要格式化输出加一个%,是后面的%
print(msg)

 

posted on 2018-12-27 17:09  没有岁月可回头  阅读(2510)  评论(0编辑  收藏  举报