码迷,mamicode.com
首页 > 编程语言 > 详细

05_Python Format Operation

时间:2018-01-25 21:51:30      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:body   格式化   mat   res   gpo   ati   color   blog   div   

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

标签:body   格式化   mat   res   gpo   ati   color   blog   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!