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之固定樣式輸出