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 8530315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:13:53+00:00 2026-06-11T09:13:53+00:00

I knew that I could get unicode characters using the escape sequence, like this:

  • 0

I knew that I could get unicode characters using the escape sequence, like this:

>>> print "\3"
♥

and I just wanted to look through available ASCII characters and written this:

for i in xrange(1, 99):
    print "\%o" % i

and it prints “\1”, “\2”, “\3”, etc., so not unicode characters. I then tried it using %s, %r, and %d and none of those seem to work either.

It was much more interesting than seeing available ASCII characters so I started reading about string formating and ended up with this piece working:

for i in xrange(1, 99):

    print "{:c}".format(i)

The question is – why the initial code wasn’t working?

  • 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-06-11T09:13:54+00:00Added an answer on June 11, 2026 at 9:13 am

    Escape sequences in string literals are processed at “parse time”, not at “run time”.
    If you write

    "\%o"
    

    Python parser sees a backslash followed by a percent sign and because this is not a valid escape sequence it will just keep both characters and then will also add o as a normal character (note that in this Python is different from e.g. the C++ programming language that it would have interpreted that string just as "%o" because in that language a backslash before a percent sign is interpreted as a percent sign only).

    At run time the formatting operator will see as left side a string composed by three characters, a backslash and a %o sequence and that is the part that will be replaced by the right-hand side giving for example the string "\\1" for the input value 1 and that string is displayed as \1.

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

Sidebar

Related Questions

When I wanted to get Android source code, I knew that I have to
I knew that java.util.Calendar class method getInstance() returns a GregorianCalendar but how could i
I was wondering if anyone knew of a way that I could feed an
i was wondering if any of you knew how to get access to that
This may seem like a programming 101 question and I had thought I knew
facebook has the facebook credit and I knew that they are testing on pay
What is Rhino.Python ? I came across it and also knew that it can
I knew this day would come, so I guess it is here. (P.S. I
I was wondering if anyone knew of where I could find an example XML
(Since this is my first SO question, let me just say I hope it's

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.