replace find join

>>> s='spam'

>>> s=s.replace('m','111')

>>> s

'spa111'

 

>>> where=s.find('11')

>>> where

3

>>> s=s[:where]+'eggs'+s[(where+2):]

>>> s

'spaeggs1'

 

>>> L=list(s)

>>> L

['s', 'p', 'a', 'e', 'g', 'g', 's', '1']

>>> s=''.join(L)    #把对象插入到join的参数内,插入位置为参数内分隔符的位置,以对象作为分隔符  

>>> s

'spaeggs1'

>>> 'spam'.join(['aaa','bbb','ccc',])    #S.join(iterable) -> str    Return a string which is the concatenation of the strings in the iterable.  The separator between elements is S.

'aaaspambbbspamccc'

posted @ 2018-03-31 10:47  我们分头打钱!  阅读(89)  评论(0编辑  收藏  举报