day05_04 数据类型-数值布尔值字符串简介
Posted darkalex001
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了day05_04 数据类型-数值布尔值字符串简介相关的知识,希望对你有一定的参考价值。
pycharm小技巧,一般情况下都需要在代码前注释以下作者以及创建日期
但是如何让软件默认生成呢?
格式化输出
可以用占位符
%s string的缩写
#__author:Administrator #date:2017/9/8 name = input("Name:") age = input("Age:") job = input("Job:") salary = input("Salary:") print(name,age,job,salary) msg = \'\'\' -------info of %s------ Name: %s Age: %s JOb: %s Salary: %s -------end------ \'\'\' % (name,name,age,job,salary) print (msg)
#__author:Administrator #date:2017/9/8 name = input("Name:") age = int(input("Age:")) job = input("Job:") salary = input("Salary:") print(name,age,job,salary) msg = \'\'\' -------info of %s------ Name: %s Age: %s JOb: %s Salary: %s You will be retired in %s years -------end------ \'\'\' % (name,name,age,job,salary,65-age) print (msg)
#__author:Administrator #date:2017/9/8 name = input("Name:") age = int(input("Age:")) job = input("Job:") salary = input("Salary:") if salary.isdigit(): #长得想不想数字,比如200d,\'200\' salary = int(salary) else: print("must input digit") print(name,age,job,salary) msg = \'\'\' -------info of %s------ Name: %s Age: %s JOb: %s Salary: %s You will be retired in %s years -------end------ \'\'\' % (name,name,age,job,salary,65-age) print (msg)
全部注释:ctrl+/
%d就表示必须输入数字
占位符:
%s s = string
%d d = digit 整数
%f f = float 浮点数,约等于小数
补充修改以下以上的错误代码
以上是关于day05_04 数据类型-数值布尔值字符串简介的主要内容,如果未能解决你的问题,请参考以下文章