python字符串中插入字符串

Sometimes you have to insert a string into the middle of another string, like "C" into "ABDE" so it becomes "ABCDE".

view source print ?
def insert(original, new, pos):
'''Inserts new inside original at pos.'''
return original[:pos] + new + original[pos:]


引自:http://twigstechtips.blogspot.com/2010/02/python-insert-string-into-another.html

你可能感兴趣的:(Python,python,string,insert,2010,c)