码迷,mamicode.com
首页 > 编程语言 > 详细

Python之固定样式输出

时间:2018-04-18 19:14:15      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:info   form   样式   input   put   inf   int   for   nbsp   

输出样式为:

---------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之固定样式输出

标签:info   form   样式   input   put   inf   int   for   nbsp   

原文地址:https://www.cnblogs.com/huizaia/p/8875960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!