zoukankan      html  css  js  c++  java
  • pytony格式化输出-占位符

    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)
  • 相关阅读:
    活动安排问题
    完美字符串
    Codeforces Round #696 (Div. 2) 解题报告
    Codeforces 1459D
    Codeforces 25D
    POJ 1847
    LightOJ 1074
    POJ 3159
    POJ 1511
    POJ 1502
  • 原文地址:https://www.cnblogs.com/dingkailinux/p/8279999.html
Copyright © 2011-2022 走看看