Why aren't there 2 newlines, when Python says there are 2 newlines? -


i have bit of text i'm fetching web api, , it's confounding me trying use python split paragraphs on double newlines.

here's smallest sample of intriguing text:

>>> print my_string e  n 

looks 2 newlines, , python agrees:

>>> print my_string.count('\n') 2 

trying replace newlines delimiter. i'm expecting eaan:

>>> print my_string.replace('\n', 'a') 

weird. here's text in hex:

87654321  0011 2233 4455 6677 8899 aabb ccdd eedff  0123456789abcdef 00000000: 650a 0a4e                                 e..n 

i'm new looking @ in hex, see 2 0a characters expect them, no other control characters (so no crlf wonkiness).

is there in text or python's interpretation of them i'm missing?

as control, typed same string in idle , tried same functions:

my_string = """e  n""" >>> my_string.count('\n') 2 >>> my_string.replace('\n', 'a') 'eaan' 

the web api tomcat's jmx interface. here's path i'm using query api (and know it's uri-escaped, that's fine):

manager/jmxproxy?qry=catalina:j2eetype=webmodule,name=//localhost/*,j2eeapplication=none,j2eeserver=none 

thank you.

solution

they crlf's:

>>> print repr(my_string) 'e\r\n\r\nn' 

i duped myself "copying-pasting" text interpreter emacs, did hex analysis. writing file , opening in emacs showed me error of ways.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -