首页 > 编程语言 > 详细

05_Python Format Operation

时间:2018-01-25 21:20:53      阅读:245      评论:0      收藏:0      [点我收藏+]

Python格式化输出

print(name: %s,version: %s,code: %d %(Python,3.6,3))

print(name: {name},version: {version},code: {code} %{name:Python,version:3.6 ,code:3})

 

Python字符串格式化

#{}  不能重复  有序
res = name: {},version: {},code: {}.format(Python,3.6,3)
#{0} 可以重复  有序
res1 = name: {0},version: {1},code: {1}.{0} is an easy to learn.format(Python,3.6,3)
#{name} 键值对 无序
res2 = name: {name}, version: {version}, code: {name} {code}.is an easy to learn.format(name = Python,version = 3.6,code = 3)
print(res)
print(res1)
print(res2)

 

05_Python Format Operation

原文:https://www.cnblogs.com/weihengblog/p/8353128.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!