标签:tps orm alt inf info int print you 参考
有两种常用的格式化输出:
第一种:
name = ‘lilei‘
money = 1000.500
print(‘hi,%s you have $%.1f‘%(name,money))
第二种:
name = ‘lilei‘
money = 1000.500
print(‘hi,{0} you have ${1:.2f}‘.format(name,money)) #.2f表示取小数点2位,1表示顺序取值,对应索引;
对应上面两种情况的结果:
更加详细信息,可参考菜鸟教程:
https://www.runoob.com/python/att-string-format.html
标签:tps orm alt inf info int print you 参考
原文地址:https://www.cnblogs.com/pengjt/p/11532249.html