Author: Alon_cheng
Date:2018-05-26 23:42:12
格式化输出(占位符)
%s(字符串) %d(整形) %f(浮点数)
(1)%f
%f ——保留小数点后面六位有效数字
%.3f,保留3位小数位
格式化输出(占位符) %s(字符串) %d(整形) %f(浮点数) name=input(‘You Name:‘) age=int(input(‘You age:‘)) job=input(‘You job:‘) salary=input(‘You salary:‘) if salary.isdigit(): salary=int(salary) else: print(‘输入错误,请输入数字‘) msg_geshihua=‘‘‘ -----------Welcome to %s----------- Name:%s age:%d job:%s salary:%s You will retire for %d years ----------- END ----------- ‘‘‘%(name,name,age,job,salary,65-age) print(msg_geshihua)
原文:https://www.cnblogs.com/aloncheng/p/9094816.html