python 中字符串的格式化

# 字符串格式化
name = input("name:")
age = int(input("age:"))
job = input("job:")
salary = input("salary:")

if salary.isdigit(): # 判断是否是数字
salary = int(salary)
# else:
# # print("please input digit")
# # exit()
# exit("please input digit") # 退出程序


msg = '''
------info of %s------
name:%s
age:%s #%d
job:%s
salary:%s #%d
You will be retired in %s year
-------end-------
''' % (name, name, age, job, salary, 65-age)
print(msg)
posted @ 2017-11-26 11:19  飘零0  阅读(169)  评论(0编辑  收藏  举报