首页 > 代码库 > python格式化输出

python格式化输出

 
python的格式化输出
技术分享
 1 __author__ = meng
 2 
 3 name = input("name:")
 4 age = int(input("age:"))
 5 job = input("job:")
 6 salary = input("salary:")
 7 
 8 info = ‘‘‘
 9 --------- info of %s -------
10 Name:%s
11 Age:%d
12 Job:%s
13 Salary:%s
14 ‘‘‘ %(name,name,age,job,salary)
15 print (info)
16 
17 info2 =‘‘‘
18 --------- info of {_name} --------
19 Name:{_name}
20 Age:{_age}
21 Job:{_job}
22 Salary:{_salary}
23 ‘‘‘.format(_name=name,
24            _age=age,
25            _job=job,
26            _salary=salary)
27 print (info2)
View Code

 

python格式化输出