Alex Rivera | Logout

What does a leading `\x` mean in a Python string `\xaa`

Asked 2010-04-20T03:25:16.333
100

What is difference between 'aa' and '\xaa'? What does the \x part mean? And which chapter of the Python documentation covers this topic?

Edit
Report

1 Answer

144

The leading \x escape sequence means the next two characters are interpreted as hex digits for the character code, so \xaa equals chr(0xaa), i.e., chr(16 * 10 + 10) -- a small raised lowercase 'a' character.

Escape sequences are documented in a short table here in the Python docs.

answered 2010-04-20T03:28:35.073

Your Answer