Answers for "python replace \n with something else"

1

python replace n with actual new line

#Just print the text and copy from console
print(f"A \n B \n C")
#output:
# A
# B
# C
Posted by: Guest on March-05-2021
0

python replace \n with something else

>>> import re
>>> re.sub('\r?\n', ' $ ', 'a\r\nb\r\nc')
'a $ b $ c'
>>> re.sub('\r?\n', ' $ ', 'a\nb\nc')
'a $ b $ c'
Posted by: Guest on March-30-2021

Code answers related to "python replace \n with something else"

Python Answers by Framework

Browse Popular Code Answers by Language