Here is one of the options with the help of rethe regular expression module ([a-zA-Z])(\d+), which corresponds to one letter, followed by numbers and sub, you can enclose coincident numbers with two brackets in replacement:
import re
s = "k0+k1+k1k2+k2k3+1+12"
re.sub(r"([a-zA-Z])(\d+)", r"\1[\2]", s)
, , :
re.sub(r"([a-zA-Z])(\d+)", lambda p: "%s[%s]" % (p.groups(0)[0].upper(), p.groups(0)[1]), s)