zoukankan      html  css  js  c++  java
  • 字符格式化输出

    字符格式化输出
      占位符 %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是否为整型
      计算机中, 一切皆为对象
      世界万物,皆为对象,一切对象皆可分类




  • 相关阅读:
    H5图片上传、压缩
    数据库基本操作
    数组遍历
    CURL
    获取IP
    Memcached的实战笔记
    修bug总结 (基于java语言)
    java开发工作的总结
    多线程测试类
    可清除的单例对象获取类
  • 原文地址:https://www.cnblogs.com/zzzhao/p/11336118.html
Copyright © 2011-2022 走看看