格式化输出
格式化输出
前面加占位符,后面加输出的数据,要一一对应
1 name = input("姓名") 2 age = input("年龄") 3 hight = int(input("身高")) 4 msg = "我叫%s,今年%s,身高%d" %(name,age,hight) 5 print(msg)
段落输出用三引号
name = input("姓名") age = input("年龄") hight = int(input("身高")) msg ='''---------user--------- name:%s age:%d hight:%d ----------------------''' %(name,int(age),hight) print(msg)
输出%的时候,用双%
name = input("姓名") age = input("年龄") hight = int(input("身高")) msg = "我叫%s,今年%s,身高%d,11%%" %(name,age,hight) print(msg)