Python Forum
Python convert multi line into single line formatted string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python convert multi line into single line formatted string
Hi, Pls help me on the below issue. I have tried a lot, but not getting correct format.

I have a python flask application where I am getting inputs from a User and POST to JIRA application to create ticket.

One of my field is description and it is a multi-line field.

Expected Input: [in description field, which is multi-line]

Expected output format: [Need in this format for JIRA post rest api process]

I tried so far,
b=request.form['description'] # I gave multi-line inputs in this field thru front end UI screen
out=a.replace("\n", "\\n")
What is the behavior you are observing and what is your expectation?
(Dec-23-2019, 06:48 AM)Malt Wrote: What is the behavior you are observing and what is your expectation?

Currently, I am getting an output like below

#input - multi line input thru front end UI screen


#to support jira rest api format, I need formatted string like below

I just tried like below and got expected output (able to post successfully in JIRA to create ticket)
Pls let me know, if any other efficient way to handling this string format.

#get input from UI screen and place in multi line quote string
#convert each line into array list

for i in format_desc:

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to input & output parameters from command line argument shantanu97 1 86 Apr-13-2021, 02:12 PM
Last Post: Larz60+
  Parse String between 2 Delimiters and add as single list items lastyle 5 144 Apr-11-2021, 11:03 PM
Last Post: lastyle
  Convert String of an int array to a Numpy array of ints mdsousa 5 295 Apr-08-2021, 08:00 PM
Last Post: mdsousa
  How to make input come after input if certain line inserted and if not runs OtherCode Adrian_L 6 326 Apr-04-2021, 06:10 PM
Last Post: Adrian_L
Exclamation Why there's a 'blank line' on CSV file? brunolelli 4 230 Mar-25-2021, 03:43 AM
Last Post: buran
  how to connect mysql from txt 1 line goes good but not all lines in text kingceasarr 4 248 Mar-24-2021, 05:45 AM
Last Post: buran
  Printing a specific line from a JSON serpiente 4 393 Mar-14-2021, 07:27 PM
Last Post: buran
  Syntax error on line 29 manwithjeans 3 252 Feb-27-2021, 08:28 AM
Last Post: perfringo
  Why not getting return on line #16? jahuja73 12 659 Feb-12-2021, 02:48 PM
Last Post: deanhystad
  How to skip to a different line while importing a different script kat_gamer 2 218 Feb-03-2021, 04:10 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020