美文网首页
基础篇7-基本数据类型1.3

基础篇7-基本数据类型1.3

作者: 梦归游子意 | 来源:发表于2017-01-16 15:28 被阅读0次
  • replace()
#a没有变
a = 'this is a dog'
b = a.replace('this', 'that')
  • find()
x = a.find('dog')#x = 10
y = a.find('asfdf')#y = -1
  • format()
'this is {1} {0}'.format('world', 'my')
'this is {whose} {fruit}'.format(fruit = 'apple', whose = 'my')
  • %
a = 'this is %(whose)s %(fruit)s' % {'fruit':'apple', 'whose':'my'}

相关文章

网友评论

      本文标题:基础篇7-基本数据类型1.3

      本文链接:https://www.haomeiwen.com/subject/cbzubttx.html