0

Is it possible to convert a string literal to a string object variable that holds a value in python?

x_value="cloud". variable ="x" Y= variable+"_value" print(Y) This will print the literal "x_value". Can I make it print "cloud" I was trying to print something something similar to echo ${variable}_value.

12th Nov 2019, 7:46 PM
Krishnakumar Venkatraman
Krishnakumar Venkatraman - avatar
1 Resposta
+ 1
Thank you ~ swim ~ . I found one other option. Python eval. Y= eval(variable+"_value")
19th Nov 2019, 5:45 AM
Krishnakumar Venkatraman
Krishnakumar Venkatraman - avatar