Answer the question
In order to leave comments, you need to log in
How to find all line breaks in a text?
How can you solve the problem of such a plan: Find all line breaks (paragraphs, lists, etc.) in the text and replace them with the character "\n" without quotes.
I don’t ask you to write a ready-made function, tell me the algorithm of actions or what modules can I use here?
It is clear that you need to look for characters in the text and change them to \n, but I don’t understand in what form they can be.
For example the list character • would be unicode '\U2022' or '•'...
Answer the question
In order to leave comments, you need to log in
You can use regular expressions, or you can use the replace() function:
stroka = '''
• Строка1
• Строка2
• строка3
'''
r = stroka.replace('•', '\\n')
print(r)
>>>
\n Строка1
\n Строка2
\n строка3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question