编程语言
首页 > 编程语言> > Python学习笔记:格式化输出

Python学习笔记:格式化输出

作者:互联网

%d  digit
%s string
%f float
程序运用:
name = input("please input your name:")
age = int(input("please input your age:"))
job = input("please input your job:")
hometown = input("please input your hometown:")
info = '''
----- info of %s -----
Name: %s
Age : %d
Job : %s
Hometown: %s
---------- end --------
''' %(name,name,age,job,hometown)

print(info)

 

程序运行结果:

please input your name:leiyu
please input your age:28
please input your job:IT
please input your hometown:四川

----- info of leiyu -----
Name: leiyu
Age : 28
Job : IT
Hometown: 四川
---------- end --------

 

标签:格式化,name,Python,hometown,please,笔记,job,input,your
来源: https://www.cnblogs.com/leiyu567567/p/11276258.html