字符格式化输出

字符格式化输出
  占位符 %s      s = string
  %d         d = digit 整数
  %f        f = float 浮点数,约等于小数

name = input("Please input your name :")
sex = input("Please input your sex :")
age = input("Please input your age :")
if age.isdigit():
age = int(age)
else:
print("You must input a digit")
job = input("Please input your job :")
salary = input("Please input your salary :")
msg = """---------info of %s-----------
Name = %s # %是占位符,s为字符串类型
Sex = %s
Age = %s
Job = %s
Salary = %s
You will be retired in %s years !
---------------end-------------""" %(name,name,sex,age,job,salary,65-age)

print(msg)

字符串
  salary.isdigit()  校验salary是否为整型
  计算机中, 一切皆为对象
  世界万物,皆为对象,一切对象皆可分类




原文地址:https://www.cnblogs.com/zzzhao/p/11336118.html