# python 的 replaceAll
def replaceAll( input, toReplace, replaceWith ): #
while ( input.find( toReplace ) > -1 ):
input = input.replace( toReplace, replaceWith )
return input
#
調用它:
file = 'q123q456q'
toReplace = 'q'
replaceWith = '-'
file = replaceAll( file, toReplace, replaceWith )
print( file ) # 打印結果 -123-456-