A
A
alekseyizmaylov2019-06-09 07:52:34
Python
alekseyizmaylov, 2019-06-09 07:52:34

How to get rid of text wraps?

Good day everyone, please help me solve this issue:
there is a program, it has large blocks of text, the program, depending on the options selected by the user, forms a certain text;
when I insert blocks of text into the code in Pycharm, they do not fit into the window, the lines are still long, I have to cut the lines with hyphens into pieces so that there is readability;
when the program outputs the result, readability is naturally preserved;
but when I want to copy this resulting text into a text editor, I have to do the reverse work, remove extra line breaks there.
How to make the text in the code editor read normally and inserted in the text editor not in pieces, but in paragraphs, as needed ???
I'm new to Python, I write for myself, for design work, the language is really good, but this problem bothers me a lot ((

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FulTupFul, 2019-06-09
@alekseyizmaylov

Save the text in separate text files and just read them when needed.

with open("success.txt", "r") as f:
    success_text = f.read()

I
Ivan Yakushenko, 2019-06-09
@kshnkvn

Alternatively, you can use a multi-line block:

text = '''
    Многострочный текст.
    Много-многострочный текст.
    Много-много-многострочный текст.
    Много-много-много-многострочный текст.
'''

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question