Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:31:35+00:00 2026-05-14T15:31:35+00:00

I was experimenting with ‘\’ characters, using ‘\a\b\c…’ just to enumerate for myself which

  • 0

I was experimenting with ‘\’ characters, using ‘\a\b\c…’ just to enumerate for myself which characters Python interprets as control characters, and to what. Here’s what I found:

\a - BELL
\b - BACKSPACE
\f - FORMFEED
\n - LINEFEED
\r - RETURN
\t - TAB
\v - VERTICAL TAB

Most of the other characters I tried, ‘\g’, ‘\s’, etc. just evaluate to the 2-character string of a backslash and the given character. I understand this is intentional, and makes sense to me.

But ‘\x’ is a problem. When my script reaches this source line:

val = "\x"

I get:

ValueError: invalid \x escape

What is so special about ‘\x’? Why is it treated differently from the other non-escaped characters?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:31:35+00:00Added an answer on May 14, 2026 at 3:31 pm

    There is a table listing all the escape codes and their meanings in the documentation.

    Escape Sequence    Meaning                        Notes
    \xhh               Character with hex value hh    (4,5)
    

    Notes:

    4. Unlike in Standard C, exactly two hex digits are required.
    5. In a string literal, hexadecimal and octal escapes denote the byte
    with the given value; it is not necessary that the byte encodes a character
    in the source character set. In a Unicode literal, these escapes denote a
    Unicode character with the given value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Experimenting with a battery monitor icon at the moment in Python using pygtk and
Experimenting with android game development. I'm using PNG format for images, and was wondering
I'm experimenting with a tagging system which is a many-to-one relationship. My schema is:
I've started experimenting with Hudson as a build server. I'm using subversion and have
While experimenting with iPhone app development, we have several AppIDs which should be deleted
I am currently experimenting with various input controls and have stumbled upon SneakyInput, which
I'm experimenting with using couchdb as a message store and would like to report
Experimenting with new features of T-SQL, I've run into a puzzle. Here is some
Just experimenting and learning, and I know how to create a shared dictionary that
Just experimenting with different inheritance techniques in JS, and came across something mildly discomfiting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.