use position in format string

This commit is contained in:
Radovan Bast 2016-07-23 16:02:40 +02:00
parent 2374f5bbed
commit 08d0a6837b

View File

@ -3,7 +3,7 @@ def replace(s, d):
if isinstance(s, str):
for var in findall(r"%\(([A-Za-z0-9_]*)\)", s):
s = s.replace("%({})".format(var), str(d[var]))
s = s.replace("%({0})".format(var), str(d[var]))
return s