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'

原文地址:https://www.cnblogs.com/wawawawa-briefnote/p/8681269.html