Replacing Microsoft Word newline character in Python

It looks like it should be easy, but I am having trouble clearing the newline character in the content pasted from Microsoft Word. Not a complete line break, but a character CTRL ENTERthat appears as a back arrow in Word. I tried to chr(10)

, chr(13)

, \u000D

, \u000A

and a few others, but I can not compare it with string.replace (). Should I be looking for a different character or should I use something other than a method string.replace

?

0


a source to share


2 answers


Run this:

print repr(mystringobject)

      



This will give you a hint which character you want to remove.

If there is still no clue, paste the result of the above command into the question and I will edit my answer.

+4


a source


you can get the ASCII value of that character like this:

for c in 'string':
    print ord(c), hex(ord(c))

      



Once you know the code, you should kill the criminal easily.

+2


a source







All Articles