字符串--3 如何修改字符串之replace,find
>>> a = "this is word!"
>>> print a
this is word!
>>> a.replace("this","that")
'that is word!'
>>> a=a.replace("this","that1")
>>> print a
that1 is word!
>>> a.find('word')
9
>>> a.find('no')
-1
>>> a.find('woord')
-1
>>> a.find('word')
9
>>> a[8]
' '
>>> a[9]
'w'
>>> a[9:]
'word!'
>>> a1 = "this is %s %s" %("my","apple")
>>> print a1
this is my apple
>>> b1 = "this is {} {}" .format("apple","my")
>>> print b1
this is apple my
>>> b1 = "this is {1} {0}" .format("apple","my")
>>> print b1
this is my apple
>>> b2 = "this is {whose} {fruit}" .format(fruit="apple",whose="my")
>>> print b2
this is my apple
>>>