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