Well, let’s say we have such examples (in python)
print (repr ("& nbsp;")) (if you copy this example through the question preview, then \ xa0 will be replaced by a space, and if through the editor (edit), it will not be replaced)
print (repr (""))
In fact, they are no different, but in the first character \ xa0, and in the second a space.
So what is this symbol? Why is it needed?
Answer 1, authority 100%
These are different characters:
& gt; & gt; & gt; import unicodedata & gt; & gt; & gt; unicodedata.name ("\ xa0") 'NO-BREAK SPACE' & gt; & gt; & gt; unicodedata.name ("\ x20") 'SPACE'
The purpose of NO-BREAK SPACE (non-breaking space ) to prevent automatic line breaks from appearing in its place.
Non-printable characters are escaped in repr, so NO-BREAK SPACE becomes \ xa0, but normal SPACE remains as it is:
& gt; & gt; & gt; "\ x20" .isprintable () # SPACE True & gt; & gt; & gt; "\ xa0" .isprintable () False
Answer 2, authority 50%
\ xa0 is non-breaking space .
The difference is described in wiki :
A computer text encoding element displayed inside a string
like a regular space, but does not allow display programs and
print to break the line at this point. Used for automation
layout, the rules of which prescribe to avoid line breaks in
known cases (mostly for readability).