How to remove escape-sequence from list elements in python?

183
September 06, 2019, at 4:40 PM

I have a list and every element of list consists of an escape sequence "\n" .. How to remove these "\n" from the elements?

Answer 1

Like this:

lst = ['\n', 'hello\n']
new_lst = [entry.replace('\n','') for entry in lst]
print(new_lst) #['', 'hello']
Rent Charter Buses Company
READ ALSO
How can I open visual studio code from Python?

How can I open visual studio code from Python?

I am trying to write a simple script, which will be opening Visual Studio Code whenever I execute it

186
Get return value from disConnect on subscription in ApolloServer

Get return value from disConnect on subscription in ApolloServer

I use ApolloServer to create a server for queries, mutations and subscription

139
Converting XMLDocument object to String in Javascript

Converting XMLDocument object to String in Javascript

I want to convert XMLDocument object that I'm getting as a response from an ajax request, to a stringI tried using

863
calling a function in componentDidMount react native

calling a function in componentDidMount react native

I am trying to call a function upon mounting a component, this function controls some state manipulationsI am not sure I am doing it right

162