2.8 Python的格式化输出

我是小菜鸡,只写最基本的,高级版本的后面用到了再说 --2018/11/27

  • %d 数值
  • %s 字符串
  • %f 浮点型

举例说明

c1 = 'lily'
c2 = 18
c3 = 1.123
print("My name is %s"%c1)
print("number is : %d " %c2 )
print("the float is : %f " %c3)
print("the float is : %.3f " %c3)
print("my name is %s , my age is %d"%(c1,c2))

结果输出

My name is lily
number is : 18 
the float is : 1.123000 
the float is : 1.123 
my name is lily , my age is 18

你可能感兴趣的:(2.8 Python的格式化输出)