0

See this code:

my_src_str = '"""hello"""'

my_real_str = get_real_string_from_python_src_string(my_src_str)

In this case, my_src_str is a string representation in python source code format. I want to interpret it as a real python string. Here I want to get hello to my_real_str. How can I do this?

1 Answer 1

3
>>> import ast
>>> my_src_str = '"""hello"""'
>>> ast.literal_eval(my_src_str)
'hello'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.