Author:uljfangbr/>E-mail:[email protected]
Mentor:Liu Youyuan
Time:2018-3-25
要求:
1.用户输入相关信息
2.打印出如下格式:
----------INFO: NAME ----------
NAME:
AGE:
JOB:
SALARY:
#! usr/bin/env python
#Author:uljfang
#E-mail:[email protected]
#Mentor:Liu Youyuan
#Time:2018-3-25
#用连接+符号处理信息
#用户信息输入
name =input("name:")
age = input("age:")
job = input("job:")
salary = input("salary:")
info=‘‘‘
------------shopping list:‘‘‘+name+‘‘‘-------------------
name:‘‘‘+name+"‘
age:‘‘‘+age+‘‘‘
job:‘‘‘+job+‘‘‘
salary:‘‘‘+salary+‘‘‘
‘‘‘
print(info.upper())
+号连接符,占用内存过多,效率不高
#! usr/bin/env python
#Author:uljfang
#E-mail:[email protected]
#Mentor:Liu Youyuan
#Time:2018-3-25
#用%s符号处理信息
#用户信息输入
name =input("name:")
age = input("age:")
job = input("job:")
salary = input("salary:")
info=‘‘‘
-----shopping list:%s-------
name:%s
age:%s
job:%s
salary:%s
‘‘‘ %(name,name,age,job,salary)
print(info.upper())
#! usr/bin/env python
#Author:uljfang
#E-mail:[email protected]
#Mentor:Liu Youyuan
#Time:2018-3-25
#用{}.forma()t处理信息
#用户信息输入
name =input("name:")
age = input("age:")
job = input("job:")
salary = input("salary:")
info=‘‘‘
-------shopping list:{name}-----------
name:{name}
age:{age}
job:{job}
salary:{salary}
‘‘‘.format(name=name,age=age,job=job,salary=salary,)
print(info.upper())
#! usr/bin/env python
#Author:uljfang
#E-mail:[email protected]
#Mentor:Liu Youyuan
#Time:2018-3-25
#用{}.format()符号处理信息
#用户信息输入
name =input("name:")
age = input("age:")
job = input("job:")
salary = input("salary:")
info=‘‘‘
------shopping list:{0}-----------
name:{0}
age:{1}
job:{2}
salary:{3}
‘‘‘.format(name,age,job,salary)
print(info.upper())
原文地址:http://blog.51cto.com/13529340/2090902
时间: 2024-12-22 05:17:36