I think what you’re looking for is ast.literal_eval
:
>>> s = repr("ab\r")
>>> s
"'ab\\r'"
>>> from ast import literal_eval
>>> literal_eval(s)
'ab\r'
More Related Contents:
- What is the difference between __str__ and __repr__?
- Why do backslashes appear twice?
- Understanding repr( ) function in Python
- Accessing Object Memory Address
- What is the meaning of %r?
- In Python, what does ” mean?
- What does !r do in str() and repr()?
- Possible to change a function’s repr in python?
- Making object JSON serializable with regular encoder
- Python: get a frequency count based on two columns (variables) in pandas dataframe some row appers
- What is the difference between using squared brackets or dot to access a column?
- Check if something is (not) in a list in Python
- How to retry after exception?
- replace column values in one dataframe by values of another dataframe
- Comparing two .txt files using difflib in Python
- xlsxwriter: is there a way to open an existing worksheet in my workbook?
- pip install pygame – SDL.h file not found
- Plotting different colors in matplotlib [duplicate]
- Is there any Python equivalent to partial classes?
- python OpenCV – add alpha channel to RGB image
- can you add HTTPS functionality to a python flask web server?
- ‘utf-8’ codec can’t decode byte 0x92 in position 18: invalid start byte
- RegEx Get string between two strings that has line breaks
- Pandas – Compute z-score for all columns
- Sort list of strings by a part of the string
- Can I access a class variable from an instance?
- How to get the parents of a Python class?
- Creating HTML in python
- how to draw communities with networkx
- Simple way to measure cell execution time in ipython notebook