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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:29:17+00:00 2026-06-15T16:29:17+00:00

I have a fairly simple program which grabs values from a file on the

  • 0

I have a fairly simple program which grabs values from a file on the filesystem and allows the user to format them and print them. An average invocation of the script looks like this:

get-amazing-temperature -c 0 --format "%.2f"

I use that format argument to format the value so that users of the script can format numbers in clever, creative ways. The problem comes, of course, when they want to have a custom format with the degrees (U+00B0) symbol.

I’m using argparse underneath the hood. When I try something like this:

get-amazing-temperature -c 0 --format '%.2f\u00B0'

…the string literal is printed:

36\u00B0

How can I allow in unicode literals in command line arguments? I’ll only be running this script on Linux/Unix machines.

  • 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-15T16:29:18+00:00Added an answer on June 15, 2026 at 4:29 pm

    When you process the argument containing the format string, you could decode it with the “unicode-escape” codec. This will convert unicode escapes to their corresponding characters:

    >>> print x
    %.2f\u00B0
    >>> print x.decode('unicode-escape')
    %.2f°
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple set of functionality for which I have multiple implementations,
I have a fairly simple Linq query (simplified code): dim x = From Product
Possible Duplicate: .eof() loop not working So I have a fairly simple C++ program
I have a fairly simple program based largely on a simple bluetooth test client
Hi I have a fairly simple program but I am having trouble understanding why
I have a fairly simple program, I write to a string with snprintf, if
I have a fairly simple web2py form with a few validators like, IS_FLOAT_IN_RANGE(...) on
I have a fairly simple question, however the answer seems to elude me. If
I have a fairly simple query: SELECT invoice_id WHERE employee_id = 'XXXX' AND customer_id
I have a fairly simple block of code. Sub Run(Name) on error resume next

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.