Reputation: 8030
I'm trying the following:
>>> a = '\01'
>>> a
>>> '\x01'
>>> b = '\11'
>>> b
>>> '\t'
>>> c = '\21'
>>> c
>>> '\x11'
I don't understand why sometimes I get hexadecimal representation and other times not.
In '\xhh' the 'x' is fundamental or not?
Upvotes: 0
Views: 790
Reputation: 63737
You see the hexadecimal representation for those characters for which your native code page cannot represent your characters
Assuming you are using windows, and your default code page is cp1252
, '\01'
is a non-printable character, an ascii control code, which stands for Start of Heading
. As there is no known printable representation of the character, a hexadecimal value is used to display the value.
Upvotes: 5
Reputation: 7331
The numbers \11, \21 are OCTAL numbers. \11 octal is \x09 (hex) is equal to '\t' (tab char). \21 octal is \x11 hex is 17 decimal.
Upvotes: 1