在 Python 字符串“ xaa”中,前导的“ x”是什么意思

'aa''\xaa'有什么不同?\x部分是什么意思?Python 文档的哪一章涵盖了这个主题?

97286 次浏览

That's unicode character escaping. See "Unicode Constructors" on PEP 100

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.