Python之固定样式输出
Posted 辉辉辉辉a
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python之固定样式输出相关的知识,希望对你有一定的参考价值。
输出样式为:
---------Info of aaa--------
name:aaa
age:23
job:IT
salary:20000
方法一:
name =input("name:")
age =input("age:")
job =input("job:")
salary =input("salary:")
info =
---------Info of %s--------
name:%s
age:%s
job:%s
salary:%s
%(name,name,age,job,salary)
print(info)
方法二:
name =input("name:")
age =input("age:")
job =input("job:")
salary =input("salary:")
info =
---------Info of {_name}--------
name:{_name}
age:{_age}
job:{_job}
salary:{_salary}
.format(_name=name,
_age=age,
_job=job,
_salary=salary)
print(info)
方法三:
name =input("name:")
age =input("age:")
job =input("job:")
salary =input("salary:")
info =
---------Info of {0}--------
name:{0}
age:{1}
job:{2}
salary:{3}
.format(name,age,job,salary)
print(info)
以上是关于Python之固定样式输出的主要内容,如果未能解决你的问题,请参考以下文章