2.8 Python的格式化输出

2018-11-27  本文已影响0人  要树立远大的理想

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

举例说明

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
上一篇 下一篇

猜你喜欢

热点阅读