How to detect invisible characters in python strings?

SHORT VERSION

I am retrieving a database value that contains a short but complete HTML structure. I want to remove all HTML tags and just cast to a single value. The HTML surrounding my relevant information is always the same, and I just need to find out which lines are broken into lines, tabs or spaces contained in the line so that I can make a match and delete it.

Is there a place where I can insert a string on the Internet, or another way to check the actual contents of a String so that I can delete it?

LONG VERSION, and what I have already tried:

The string is retrieved from the HP Quality Center database and printed in the automatic test execution console, the string is interpreted as two spaces. When pasted into a word, eclipse, or QC script editor, it appears as a string.

I tried replacing spaces with \n , double whitespace and ¶ . Nothing works.

I am translating this script from working VBScript. Problem invisible characters are defined as vbcrlf and vbcrlf . For some reason, they use lowercase in replacing String before the corresponding parameter value and upper case in the string that appears after my corresponding substring. They are defined as variables and are not inside the line itself: <html>"&vbcrlf&"<body>"&vbcrlf&"<div ...

This website suggests that I should use \n https://answers.yahoo.com/question/index?qid=20070506205148AAmr92N as they write:

vbCrLf = "\ n" # Carriage return line return coefficient

I am a bit confused about the upper / lower case mismatch here though ...

EDIT:

After you sent the returnlinefeed combination to Google Carriage, I found out that it can be defined as /r/n here: Carriage return order and a new line feed .

But I found this for a long time, and it does not answer my question, how best can I determine exactly what invisible characters the string contains. I will leave the question open.

+7
python string
source share
1 answer

To view the contents of a string (including its "hidden" values), you can always:

 print( [data] ) # or print( repr(data) ) 

If you are on the system that you described in the comments, you can also do:

 with open('/var/log/debug.log', 'w') as fh: fh.write( str( [data] ) ) 

This, however, will simply give you a general idea of ​​how your data looks, but if it solves your question or problem, then it is great. If you need more help, edit your question or send a new one :)

+6
source share

All Articles