1. 程式人生 > >python中format的小用法

python中format的小用法

color format proc exe finish cti int code zha

 1 name = input("name:")
 2 age = input("age:")
 3 job = input("job:")
 4 salary = input("salary:")
 5 
 6 info="""
 7 ----------info of {_name}.-------------
 8 Name = {_name}
 9 Age = {_age}
10 Job = {_job}
11 Salary = {_salary}
12 """.format(_name=name,_age=age,_job=job,_salary=salary)
13 print(info)
C:\Users\zhangzhijia\venv\Scripts\python.exe D:/ZZJ/python_project/conteraction.py
name:zhang
age:27
job:IT
salary:3000

----------info of zhang.-------------
Name = zhang
Age = 27
Job = IT
Salary = 3000


Process finished with exit code 0

運用format函數,將輸入值規範的打印

python中format的小用法