I've got a string and I'd like to find and replace some numbers in it. I.e., there are multiple repetitions of "v = 324\n" in there, with different values. Now I want to divide all those numbers by n (rounded to nearest integer) and save it as a new string.
At the moment I'm using parse package:
n = 10
s = "this is v = 2342\n and another v = 231\n and some stuff..."
for r in findall("v = {:d}\\n", s):
print r
This gives me the list of Results, but I don't know how to make changes to the string. How can I do it?