python - how can I convert a char to variable? -


in detail: need formula work. string = str(z)+":1.0 "+str(z+1)+":0.0" z variable value.

will able input formula dictionary value specific key. like

dicto={'a': 'str(z)+":1.0 "+str(z+1)+":0.0"'}     

so when see key value 'a' should able use formula in dictionary

as read question, wanted this:

dicto = {'a': lambda x: "{0!s}:1.0 {1!s}:0.0".format(x, x + 1)} dicto['a'](2)   # '2:1.0 3:0.0' 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -