with eval
I am able to get the below:
str1 = "23145"
str2 = "str1"
print(str2)
Output:
23145
working well and good.
with ast.literal_eval
that is not working as expected:
import ast
print(ast.literal_eval(str2))
Getting:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Volumes/app/python/anaconda3/lib/python3.7/ast.py", line 91, in literal_eval
return _convert(node_or_string)
File "/Volumes/app/python/anaconda3/lib/python3.7/ast.py", line 90, in _convert
return _convert_signed_num(node)
File "/Volumes/app/python/anaconda3/lib/python3.7/ast.py", line 63, in _convert_signed_num
return _convert_num(node)
File "/Volumes/app/python/anaconda3/lib/python3.7/ast.py", line 55, in _convert_num
raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Name object at 0x10ce34190>