Use repr
>>> string = "abcd\n"
>>> print(repr(string))
'abcd\n'
More Related Contents:
- Remove all newlines from inside a string
- Most efficient way to build single-element list from string with or without spaces? [closed]
- Python String concatenation with in double quotes [closed]
- User input integer list [duplicate]
- How to extract numbers from a string in Python?
- String comparison in Python: is vs. == [duplicate]
- How can I fill out a Python string with spaces?
- Simpler way to create dictionary of separate variables?
- How to display a float with two decimal places?
- What does preceding a string literal with “r” mean? [duplicate]
- Python: avoid new line with print command [duplicate]
- What’s the difference between str.isdigit, isnumeric and isdecimal in python?
- Convert floating point number to a certain precision, and then copy to string
- Is there a generator version of `string.split()` in Python?
- Convert hex string to integer in Python
- Python string with space and without space at the end and immutability
- Time complexity of string concatenation in Python [duplicate]
- How to make a string’s content appears on screen as we type on keyboard? [duplicate]
- Perform a string operation for every element in a Python list
- ValueError: invalid literal for int() with base 10: ‘stop’
- Change a string of integers separated by spaces to a list of int
- How to remove empty lines with or without whitespace in Python
- How to create a list with the characters of a string? [duplicate]
- Determine the common prefix of multiple strings
- Wrap long lines in Python [duplicate]
- How to remove leading and trailing spaces from a string?
- Modifying a list while iterating when programming with python [duplicate]
- How to use str.contains() with multiple expressions in pandas dataframes
- How to merge two json string in Python?
- How does str(list) work?