Mar-17-2019, 01:17 PM
(This post was last modified: Mar-17-2019, 01:19 PM by AlekseyPython.)
Python 3.7.2
I have a specially formatted text, that I just want to post to another site:
Of course, I can save this text to a file and read it line by line, but I don't want to introduce unnecessary entities.
How to simply work with formatted text in Python?
I have a specially formatted text, that I just want to post to another site:
my_text = '\
var index_id = 0;\
var len = arr_id.length;\
while(index_id < len){\
current_id = arr_id[index_id];\
index_id = index_id + 1;\
\
offset = 0;\
if (index_query == 0){\
offset = initial_offset;\
}\
}'But if I form it as shown above, then it is a single string, that cann't be broken into substrings. And the code abounding with backslashes becomes very ugly. Of course, I can save this text to a file and read it line by line, but I don't want to introduce unnecessary entities.
How to simply work with formatted text in Python?
