标签:格式化输出 格式化 col 输出 info put color nbsp for
方法一:
1 # Author:yebo 2 name = input("name:") 3 age = int(input("age:")) 4 print(type(age)) 5 job = input("job:") 6 salary = int(input("salary:")) 7 8 #格式化输出方法一 9 info = ‘‘‘ 10 --------info of %s------- 11 Name:%s 12 age:%d 13 job:%s 14 salary:%d 15 ‘‘‘ %(name, name,age,job,salary)
方法二:
1 # Author:yebo 2 name = input("name:") 3 age = int(input("age:")) 4 print(type(age)) 5 job = input("job:") 6 salary = int(input("salary:")) 7 8 #格式化输出方法二 9 info3 = ‘‘‘ 10 -------info3 of {0}------- 11 Name:{0} 12 age:{1} 13 job:{2} 14 salary:{3} 15 ‘‘‘.format (name,age,job,salary)
方法三(推荐):
1 # Author:yebo 2 name = input("name:") 3 age = int(input("age:")) 4 print(type(age)) 5 job = input("job:") 6 salary = int(input("salary:")) 7 8 #格式化输出方法三 9 info2 = ‘‘‘ 10 -------info2 of {_name}------- 11 Name:{_name} 12 age:{_age} 13 job:{_job} 14 salary:{_salary} 15 ‘‘‘.format (_name = name,_age = age,_job = job,_salary = salary)
标签:格式化输出 格式化 col 输出 info put color nbsp for
原文地址:https://www.cnblogs.com/SongjiangCyclone/p/9373979.html