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是否为整型
      计算机中, 一切皆为对象
      世界万物,皆为对象,一切对象皆可分类




  • 相关阅读:
    第十三周学习进度
    第二次冲刺阶段每日任务02
    第二次冲刺阶段每日任务01
    构建之法阅读笔记03
    找水王续
    第十二周学习进度
    找水王
    第十一周学习进度
    博客园的用户体验
    找水王1
  • 原文地址:https://www.cnblogs.com/zzzhao/p/11336118.html
Copyright © 2011-2022 走看看