I suggest you use the method:
imgstring.replace("\n", " ")
Alternatively, if you know inbetween which words you want to remove the Newline, you can use regular expressions to find your place where to replace the newline.
A third way of doing this: You can turn the string into a list like so:
thisisanexample = "Hello \nSir!"
examplelist = list(thisisanexample)
print(examplelist) #gives ['H', 'e', 'l', 'l', 'o', ' ', '\n', 'S', 'i', 'r', '!']
and then iterate through it to find and replace all '\n'
that you don’t want.
solved How can I get a variable that holds string that has multiple lines to be only one line?