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 --------

 

上一篇:找出一个数组中的最大数、第二大数


下一篇:C语言程序设计(四)