基础篇7-基本数据类型1.3
2017-01-16 本文已影响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'}