%s d ....格式化的妙用
1 #格式化输出 2 #% s d 3 4 # name = input('请输入姓名:') 5 # age = input('请输入年龄:') 6 # height = input('请输入身高:') 7 # msg = '我叫%s,今年%s 身高%s'%(name,age,height) 8 # print(msg) 9 """ 10 name = input('请输入你的姓名:') 11 age = input('请输入你的年龄:') 12 job = input('请输入你的工作:') 13 hobbie = input('请输入你的爱好:') 14 15 msg = '''---------- info of %s ---------- 16 Name : %s 17 Age : %d 18 job : %s 19 Hobbie : %s 20 ------------- end ------------- ''' %(name,name,int(age),job,hobbie) 21 22 print(msg) 23 24 """ 25 26 name = input('请输入姓名:') 27 age = input('请输入年龄:') 28 height = input('请输入身高:') 29 msg = '我叫%s,今年%d 身高%d 学习进度为3%%'%(name,int(age),int(height)) 30 print(msg)