首页 > 其他 > 详细

字符串 格式化输出

时间:2018-06-18 14:17:07      阅读:164      评论:0      收藏:0      [点我收藏+]
name = input("name:")
age = int(input("age:"))
job = input("job:")
salary = input("salary:")

if salary.isdigit(): #长的像不像数字,比如200d。“200”
salary = int(salary)
# else:
# #print("must input digit")
# exit("must input digit")# 退出程序
#

msg = ‘‘‘
------------info of %s-----------
Name: %s
Age : %d
Job : %s
Salary: %f
You will be retired in %s vears
------------ end ---------------
‘‘‘ % (name,name,age,job,salary,65-age)
print(msg)

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

字符串 格式化输出

原文:https://www.cnblogs.com/fy414371/p/9195077.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!