私はPythonで文字列を持っていますThe quick @red fox jumps over the @lame brown dog.
@
で始まる各単語を、その単語を引数として取る関数の出力に置き換えようとしています。
def my_replace(match):
return match + str(match.index('e'))
#Psuedo-code
string = "The quick @red fox jumps over the @lame brown dog."
string.replace('@%match', my_replace(match))
# Result
"The quick @red2 fox jumps over the @lame4 brown dog."
これを行う賢い方法はありますか?