If you have a string s in the form "var=number" then you can simply do
s
"var=number"
r = s.split("=") var, number = (r[0], int(r[1])) locals()[var] = number
See this for more explanations about locals().
locals()
2.1m questions
2.1m answers
60 comments
57.0k users