首页 > 其他 > 详细

pytony格式化输出-占位符

时间:2018-01-13 20:23:49      阅读:237      评论:0      收藏:0      [点我收藏+]

1. %s  s = string  字符串

2. %d  d = digit  整数

3. %f  f = float  浮点数

#!/usr/bin/env python
#_*_coding:utf-8_*_
#date: 2018/1/13
#_author_="dingkai"

name = input("your name:")

age = input("your age:")
if age.isdigit():   #像不像数字
    int(age)
else:
    print(age must be int!)
    exit(1) #退出程序

salary = input("your salary:")
if salary.isdigit():  #像不像数字
    int(salary)
else:
    print(salary must be int!)
    exit(1) #退出程序

msg_info = ‘‘‘
------info of %s ------
name:   %s
age:    %s
salary: %s
------end------
‘‘‘ %(name,name,age,salary)

print(msg_info)

 

pytony格式化输出-占位符

原文:https://www.cnblogs.com/dingkailinux/p/8279999.html

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